given:
var regexp = new RegExp("<~~include(.*?)~~>", "g");
What’s the easist way in javascript to assign a variable to whatever’s matched by .*?
I can do this, but it’s a little ugly:
myString.match(regexp).replace("<~~include", "").replace("~~>", "");
JavaScript should return an array object on a regex match, where the zero index of the array is the whole string that was matched, and the following indexes are the capture groups. In your case, something like:
Should assign the value of the
(.*?)capture group tomyVar.