Rufnex wrote:
can anyone explain me step by step the following Regex?
reg = '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';
`-------------'`-----------'`------------'
This Regular Expression matches
"<script" followed by none or more characters that are not "\r" or
"\n" (shortest possible match)
followed by ">" (the match will not be captured)
followed by none or more of "\n", "\r" or a character that is not "\r" or
"\n" (shortest possible match, both this match and the contained
alternation are captured)
followed by "</script>" (the match will not be captured).
It is supported from JavaScript 1.5 (Mozilla/5.0), JScript 3.0 (IE 3.0;
however from other ECMAScript features I guess that non-capturing parens
and non-greedy matching were not introduced before JScript 5.5, IE 5.5 --
comments anyone?) and ECMAScript 3 on.
RTFM:
<URL:http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:RegEx p>
<URL:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsreconintroductiontoregularexpressions.asp>
PointedEars