Input:
var str = 'text {{value1}} text {{value2}}text{{value1}}';
Regex:
var result = str.match(/({{\S+}})+/ig);
Output:
["{{value1}}", "{{value2}}text{{value1}}"]
What regex should I use to get the next result:
["{{value1}}", "{{value2}}", "{{value1}}"]
Change the regex to be non-greedy:
I added a
?after the\S+. This makes the+match as few as possible.