By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,638 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

Need Regex explained

P: n/a
Hello,

can anyone explain me step by step the following Regex?

reg = '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';

thx!

Rufnex

Dec 10 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Dec 10 '05 #2

P: n/a
Hi Thomas,

big thanks to you! i just started to learn regex with js ..
Oki, i will read TFM ;o)

Rufnex

Dec 10 '05 #3

P: n/a
On 2005-12-10, Rufnex <in**@jg-webdesign.de> wrote:
Hello,

can anyone explain me step by step the following Regex?

reg = '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';


no. is that exactly as you posted it?

it looks like it might match scripts in a string containg an HTML document

--

Bye.
Jasen
Dec 11 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.