I have the following string and regex:
var string = "Dear [to name], [your name] has decided to share this [link]";
var patt = /\[+[A-Za-z0-9]+\]/;
I want to be able to change each of the bracketed variables with dynamic input. How would I use match() or replace() to target the 1st, 2nd and 3rd occurrences of this regex?
EDIT: At the moment if I do something like document.write(body.match(patt));
it will match only the last one [link]