Having a simplified example string that looks like this one:
string = "AA: 1%, BB: 2%, CC: 3%, DD: 4% and EE: 5%."
I would like to replace a part of it by matching from a pattern. I tried using gsub this way:
gsub("(BB{1}.*%{1}), ","BB: no data, ",string)
but it returns the next:
"AA: 1%, BB: no data, DD: 4% and EE: 5%."
As if it is looking for the %
simbol from the end. I would like to substitute until the next %
, not the last, keeping the CC part. The desired output:
"AA: 1%, BB: no data, CC: 3%, DD: 4% and EE: 5%."
This kind of questions often are marked as duplicate. I've been searching for half hour and nothing, so I decided to ask if some regexp masters may help.