I have a string containing something like this
"... /\*start anythingCanBeEnteredHere end\*/ ..."
I need a regex that gets only the anythingCanBeEnteredHere part, which can be a collection of any number of symbols.
The problem is that I can’t find any shortcut/flag that will choose any symbol
So far I use this regex
var regex = /start([^\~]*)end/;
var templateCode = myString.match(regex);
[^\~] chooses any symbol except "~" (which is a hack) and works fine, but I really need all symbols.
I’ve also tried this [^] but it doesn’t work right.
will match
FOOinstartFOOendandBARendBAZinstartBARendBAZend.will match
FOOinstartFOOendandBARinstartBARendBAZend.The dot matches anything except a newline symbol (
\n). If you want to capture newlines as well, replace dot with[\s\S]. Also, if you don’t allow the match to be empty (as instartend), use+instead of*.See http://www.regular-expressions.info/reference.html for more info.