Choose any symbol in javascript regex
/start(.*)end/
will match FOO
in startFOOend
and BARendBAZ
in startBARendBAZend
.
/start(.*?)end/
will match FOO
in startFOOend
and BAR
in startBARendBAZend
.
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 in startend
), use +
instead of *
.
See http://www.regular-expressions.info/reference.html for more info.
I'm not sure I understand what you mean by "symbol", if you mean anything, that's what the dot .
will match
Are you trying to do this?
var regex = /start(.*)end/;
var templateCode = myString.match(regex);