In JS, I am trying to manipulate a long plain string. I want to add new chars to each match inside the string in order to make a new string. I mean there are multiple values of the searched substring inside the long string. Any ideas?
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
Use replaceAll
If you want to append to certain text fragments, regardless of whether they are in lower or upper case you would need to use a regular expression with the flags
g
andi
and use the group braces ((
and)
) to represent each encountered occurrence: