473,385 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need Regex explained

Hello,

can anyone explain me step by step the following Regex?

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

thx!

Rufnex

Dec 10 '05 #1
3 1255
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joe | last post by:
Hi, I have been using a regular expression that I don’t uite understand to filter the valid email address. My regular expression is as follows: <asp:RegularExpressionValidator...
8
by: moondaddy | last post by:
I'm writing an app in vb.net 1.1 and I need to parse strings that look similar to the one below. All 5 rows will make up one string. I have a form where a use can copy/paste data like what you...
2
by: Michael R. Pierotti | last post by:
Dim reg As New Regex("^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$") Dim m As Match = reg.Match(txtIPAddress.Text) If m.Success Then 'No need to do anything here Else MessageBox.Show("You need to enter a...
9
by: jmchadha | last post by:
I have got the following html: "something in html ... etc.. city1... etc... <a class="font1" href="city1.html" onclick="etc."click for <b>info</bon city1 </a> ... some html. city1.. can repeat...
6
by: Gary Bond | last post by:
Hi All, Being a bit of a newbie with regex, I am confused when using word boundaries. For instance, I want to replace all the stand alone '.5k' that occur in an input string, with 500. In other...
14
by: ohmmega | last post by:
hy, i've got a simple question (for somebody who already knows the answer) about regex: i've a string like bla@bla@bla or bla@@bla i like to check the @'s, but couldn't figure it out how to set...
14
by: gezerpunta | last post by:
Hi I need a regex code for parsing this string to an email array "mnp test" <celo@tum.com>,"test testt" <otur@par.com>,sett@tttt.com,test@twest.com thanks
3
by: Jonathan Lukens | last post by:
I am in the last phase of building a Django app based on something I wrote in Java a while back. Right now I am stuck on how to return the matches of a regular expression as a list *at all*, and...
4
by: Danny Ni | last post by:
Hi, The following code snippet is causing CPU to max out on my local machine and production servers. It looks fine on Expresso though. Regex rgxVideo = new...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.