JavaScript Question I have a string like this:
"Hello my name is [[xxx]] and I love [[yyy]]"
How can I use Regex to give me the array like this: xxx, yyy ?
The regex like this [[.*?]]
used within the replace function will do the job:
var str = 'Hello my name is [[xxx]] and I love [[yyy]]';
var resultArray = [];
str.replace(/[[(.*?)]]/g, function(match,match1){
// write data to result object
resultArray.push(match1);
});
// show the result in console
console.log(resultArray);