"unescape('awefawef')unescape('efawefwf')unescape('awefawef')"
.match(/unescape\(\'([^\)]+)\'\)/gi)
If there multiple unescape(...)
matches it returns matches with unescape
, but i need only what is inside ()
brackets.
Thanks ;)
Desired output:
['awefawef','efawefwf','awefawef']
You will need to use the ungreedy operator to match only the contents of the parenthesis, and to get all results, you will need to call RegExp.exec multiple times on the same string.
var regex = /unescape\('(.+?)'\)/ig;
var string = "this unescape('foo') is a unescape('bar') test";
var result;
while(result = regex.exec(string))
console.log(result[1]);
You can get it from RegExp.$1
.
"unescape('awefawef')unescape('efawefwf')unescape('awefawef')".match(/unescape\(\'([^\)]+)\'\)/gi);
console.log(RegExp.$1); //awefawef
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With