- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
this pattern can find all lines of script in HTML code from open to close tag range
<script language=javascript>document.write("one");</script>
Author Rating: The rating for this expression. Bassel Issa
Your Rating
Bad Good

Enter New Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Use this to scripts exactly.
Name: Advice
Date: 10/31/2008 10:47:11 AM
Regex: <script[^>]*>[\w|\t|\r|\W]*?</script> Input: <script>[\w|\t|\r|\W]*</script> Not to be matched... <script>[\w|\t|\r|\W]*</script>

Title: my fix
Name: Norb
Date: 9/2/2008 1:09:28 PM
this is what i used to get a better result with this \<script[^>]*>[\w|\t|\r|\W]*?\<\/script\>

Title: I should follow up
Name: Dave S
Date: 12/22/2004 2:56:16 PM
Note: I suppose I should explain my previous post more... I began using the original expressino from Bassel: <script[^>]*>[\w|\t|\r|\W]*</script> But then changed in favour of Dave Rossow's solution (to workaround multiple occurances: <script[^>]*>(.(?!<script))*</script> but i noticed that his solution doesn't match any occurances of a "<script>" tag with whitespace like this: < script> also doesn't match: </script > So, in my previous post, i've made a modification to Dave Rossow's earlier expression. It apperas to be working for me, but I wonder if there's a better method than: script[^>]*>(.(?!<*script))*/script Cheers.

Title: Whitespace inside < script > tags
Name: Dave
Date: 12/22/2004 2:51:23 PM
< script > < /script > How could this expression be modified to match script tags if there is whitespace? perhaps: script[^>]*>(.(?!<*script))*/script Cheers. ?

Title: requires to be changed for being..end
Name: V.C.Sekhar
Date: 10/16/2004 12:44:36 AM
Hi Atticus, Please advise on how to change this expression if I should not use ^begin([\w|\t|\r|\W]*?)end$ to capture anything between the words "begin" and "end" (like in T-SQL). Thanks in advance, Sekhar

Title: This is my title
Name: Atticus
Date: 2/13/2004 3:25:36 PM
Woo! I was just looking for something like this. Here's another way to solve the multiple occurances problem... <tag>([\w|\t|\r|\W]*?)<\/tag>

Title: Multiple Occurrences Solution
Name: Dave Rossow
Date: 2/2/2004 8:15:43 PM
The solution below solves the problem of multiple occurrences. <script[^>]*>(.(?!<script))*</script>

Title: sorry for the spam
Name: Ben Hoskins
Date: 6/10/2003 8:42:38 AM
just quickly fixed this expression - it should be: &lt;script[^&gt;]*&gt;[\w|\t|\r|\W]*?&lt;/script&gt;

Title: Bug Problem
Name: Ben Hoskins
Date: 6/10/2003 8:21:23 AM
I'm using this regex for replacing script - the only problem is that if there's two or more script tags on a page it'll grab all in between... i.e. the page is: <html><head><script>somescript</script></head><body><script>somemorescript</script></body></html> say i do a replace on this string in - it'll do this: <html><head><script>somedifferentscript</script></body></html> anyone any suggestions?

Title: News Spider Product Developer
Name: Mike Martinez
Date: 3/24/2003 4:45:25 PM
How do you handle /script in C#? With escape character and all???

Copyright © 2001-2018, | ASP.NET Tutorials