RegEx expression that will capture everything between two characters including multiline blocks
Which regex engine are you using?
<%(.*?)%>
should work with the "dot matches newline" option enabled. If you don't know how to set that, try
<%([\s\S]*?)%>
or
(?s)<%(.*?)%>
No need to escape <
, %
, or >
by the way.
\<\%(.*?)\%\>
. You need to use .*?
to get non-greedy pattern matching.
EDIT To solve the multiline problem, you can't use the .
wildcard, as it matches everything except newline. This option differs depending on your regular expressions engine. So, I can tell you what to do if you tell me your regex engine.
I've been using Microsoft's Regex engine (provided by JScript in IE) and it has a 'multi-line' switch that effects the behaviour of .
, but then still I've had problems I had to resolve using [\u0000-\uFFFF]
which matches everything including EOL's or any control chars...
So have a go with <%([\u0000-\uFFFF]*?)%>