63 regular expressions found in this category!
Displaying page
of
pages;
Items to
Title |
Test
Details
XML Tag
|
Expression |
<(\w+)(\s(\w*=".*?")?)*((/>)|((/*?)>.*?</\1>)) |
Description |
This RE will match XML tag elements. All elements must be closed. Won't match nested tags
|
Matches |
<body> text<br/>More Text </body> | <a href="link.html">Link</a |
Non-Matches |
<p> Some Text <p> | <hr> | <html> |
Author |
Rating:
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
<(?:[^"']+?|.+?(?:"|').*?(?:"|')?.*?)*?> |
Description |
This will match all tags in a string, it's good for stripping HTML or XML tags to get the plain text.It works with attributes that include javascript or "<>".
It will match all these
<hr size="3"
noshade
color="#000000"
align="left">
<p style="margin-top:0px;margin-bottom:0px"
align="center"><font face="Times New Roman"
size="5"><b>UNITED STATES</b></font></p>
<input type=button onclick='if(n.value>5)do_this();'> not this <br> <input type=button onclick="n>5?a():b();" value=test> not this <br> <input type=button onclick="n>5?a(\"OK\"):b('Not Ok');" value=test> not this <br> <input type=button onclick='n>5' value=test onmouseover="n<5&&n>8" onmouseout='if(n>5)alert(\'True\');else alert("False")'> not this <br>
|
Matches |
<input type=button onclick='n>5' value=test onmouseover="n<5&&n>8" onm |
Non-Matches |
haven't found any exceptions yet |
Author |
Rating:
Toby Henderson
|
Title |
Test
Details
Pattern Title
|
Expression |
<(?<tag>.*).*>(?<text>.*)</\k<tag>> |
Description |
Match the content of any regular tag/s |
Matches |
<body>Content here</body> |
Non-Matches |
<body>Content here<body> |
Author |
Rating:
luca milan
|
Title |
Test
Details
Pattern Title
|
Expression |
&lt;/?([a-zA-Z][-A-Za-z\d\.]{0,71})(\s+(\S+)(\s*=\s*([-\w\.]{1,1024}|&quot;[^&quot;]{0,1024}&quot;|'[^']{0,1024}'))?)*\s*&gt; |
Description |
Searches for tags and there atributes according to the HTML 2.0 specification to limit length of tags to 72 characters, and length of attribute values to 1024 characters. |
Matches |
&lt;IMG src='stars.gif' alt=&quot;space&quot; height=1&gt; |
Non-Matches |
this is not a tag |
Author |
Rating:
Not yet rated.
Lewis Moten
|
Title |
Test
Details
Pattern Title
|
Expression |
<[a-zA-Z][^>]*\son\w+=(\w+|'[^']*'|"[^"]*")[^>]*> |
Description |
Find HTML tags that have javascript events attached to them. |
Matches |
<IMG onmouseover="window.close()"> |
Non-Matches |
<IMG src="star.gif"> |
Author |
Rating:
Not yet rated.
Lewis Moten
|
Title |
Test
Details
Pattern Title
|
Expression |
<[a-zA-Z]+(\s+[a-zA-Z]+\s*=\s*("([^"]*)"|'([^']*)'))*\s*/> |
Description |
Matches a valid "empty" tag (has trailing slash). Note, if you run it against a string such as <img src="test.gif" alt="<hr />"> it will indeed return a match. But, the match is not at character 1 like you'd suspect, but rather it's matching the internal <hr />. If you look at the source of this tag (http://concepts.waetech.com/unclosed_tags/) you'll find a whoe suite of regex's for matching html tags. Using them you could feasibly step though a document and avoid this mismatch as the outer tag would match *in totality* and you'd completely skip this inner match.
|
Matches |
<img src="test.gif"/> |
Non-Matches |
<img src="test.gif"> | <img src="test.gif"a/> |
Author |
Rating:
Not yet rated.
Joshua Olson
|
Title |
Test
Details
Web Colors (216)
|
Expression |
^#?(([fFcC0369])\2){3}$ |
Description |
Matches the 216 web colors with or without the '#' sign. |
Matches |
#FFFFFF | FFCC00 | 003300 |
Non-Matches |
#FFFFF | EFCC00 | 030303 |
Author |
Rating:
Not yet rated.
Dean Dal Bozzo
|
Title |
Test
Details
Pattern Title
|
Expression |
&(?![a-zA-Z]{2,6};|#[0-9]{3};) |
Description |
The goal of this regular expression is to replace all & (ampersand) characters by &amp; if they are not the start of HTML entities. I used
http://www.w3schools.com/html/html_entitiesref.asp as a reference. You can then use RegExp Replace method to do the work. Was helpful for me, might helpful be for you... |
Matches |
&ThisIsTooLong; | Lilo & Stich | &l; |
Non-Matches |
&lt; | &brvbar; | &#166; |
Author |
Rating:
Not yet rated.
Frederick Samson
|
Title |
Test
Details
Pattern Title
|
Expression |
<!--[\s\S]*?--> |
Description |
Removes pesky comments and commented javascript from HTML |
Matches |
<!-- comments --> | <!-- x = a > b - 3 --> |
Non-Matches |
<COMMENTS>this is a comment</COMMENTS> |
Author |
Rating:
Not yet rated.
Lewis Moten
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?<Code>([^"']|"[^"]*")*)'(?<Comment>.*)$ |
Description |
This expression separates a Visual Basic (VB) source code line into the code part and the comment part (if any, following an apostrophe character not enclosed in quote marks). |
Matches |
a = b ' Comment | a = "xy'z" ' Comment |
Non-Matches |
a = b | rem not supported |
Author |
Rating:
Not yet rated.
Robert Altman
|
Title |
Test
Details
Pattern Title
|
Expression |
<[^>]*name[\s]*=[\s]*"?[^\w_]*"?[^>]*> |
Description |
This RX is used to find get all named tags in an html string. If you find a problem with it, please email [email protected] |
Matches |
<input type = text name = "bob"> | <select name = "fred"> | <form |
Non-Matches |
<input type = submit> | <font face = "arial"> | The drity brown fox stank like |
Author |
Rating:
Not yet rated.
Andrew Freese
|
Title |
Test
Details
Pattern Title
|
Expression |
<blockquote>(?:\s*([^<]+)<br>\s*)+</blockquote> |
Description |
Use this regular expression pattern to get the string1, string2, string3 .... from <blockquote>string1<br>string2<br>string3<br></blockquote>
|
Matches |
<blockquote>string1<br>string2<br>string3<br></blockquote> |
Non-Matches |
.. |
Author |
Rating:
Not yet rated.
Waheed Khan
|
Title |
Test
Details
Pattern Title
|
Expression |
<[^>]*\n?.*=("|')?(.*\.jpg)("|')?.*\n?[^<]*> |
Description |
Match any image insert in a tag .
simply replace the .jpg in the pattern whit a variable of content type ex:.swf,.js,.gif and loop the pattern to retrieve all tag whit the contenttype pass trought....
Very useful when you have people uploading html document in your site and you want to retrieve all dependecy. |
Matches |
<td background="../img/img.jpg" > | <img src=img.jpg > | <img src='img.jpg' |
Non-Matches |
= img.jpg | img.jpg |
Author |
Rating:
Not yet rated.
Marc-Antoine Latour
|
Title |
Test
Details
Pattern Title
|
Expression |
^[^<>`~!/@\#}$%:;)(_^{&*=|'+]+$ |
Description |
A general string validation to insure that NO malicious code or specified characters are passed through user input. This will allow you to input any characters except those specified. The expression above does not allow user input of <>`~!/@\#}$%:;)(_^{&*=|'+. Input as many invalid characters you wish to deny. This really works! |
Matches |
This is a test |
Non-Matches |
<href = | <br> | That's it |
Author |
Rating:
Not yet rated.
Brenden Salta
|
Title |
Test
Details
Pattern Title
|
Expression |
^[a-zA-Z_]{1}[a-zA-Z0-9_]+$ |
Description |
This expression validates for valid C# or C++ identifier |
Matches |
_12ffsd | abcd123 | abcd_23232 |
Non-Matches |
..// | ..13e232 | abcd 3232 |
Author |
Rating:
Not yet rated.
Ashish Sheth
|
Title |
Test
Details
Pattern Title
|
Expression |
^(Function|Sub)(\s+[\w]+)\([^\(\)]*\) |
Description |
Updated, changed [\w]* to [\w]+ because pattern should not match Sub (), there would be no function name which would be incorrect.
Will extract function declarations from ASP or also VB I assume. Will even capture declarations that break across new lines or ones that use the underscore(line continuation character) in Microsoft's VB, VBA, ASP, etc. Had to put this together to document some code on a project and didn't see anything like it on the web. I hope it helps out anyone else who has to re-engineer ASP or VB code. |
Matches |
Function MyFunc(Arg1, Arg2, Arg3, Arg4) |
Non-Matches |
'This is a comment for MyFunc(Arg1,Arg2,Arg3) and this regexp wouldn't work. |
Author |
Rating:
Not yet rated.
James Fal
|
Title |
Test
Details
Pattern Title
|
Expression |
<([^\s>]*)(\s[^<]*)> |
Description |
grab all tags attributes...
<img src="truc"> returns :
<
(1:img)
(2: src="truc")
>
i use it to clean html pages to grab infos...
use a RegEx Replace with "<$1>" to keep only tags codes... |
Matches |
<img src="truc"> | <body background='...'> | <p align='left'> |
Non-Matches |
<br> | </body> | <p> |
Author |
Rating:
Not yet rated.
Tanguy Pruvot
|
Title |
Test
Details
Pattern Title
|
Expression |
<([^<>\s]*)(\s[^<>]*)?> |
Description |
All tags in first submatche
All attributes in second one... |
Matches |
<td class="TD2"> | <!-- comment --> | </table> |
Non-Matches |
19-Fev-2002 - 19h00 | New Changes : | ... |
Author |
Rating:
Not yet rated.
Tanguy Pruvot
|
Title |
Test
Details
Quoted string
|
Expression |
^(\x22|\x27)((?!\1).|\1{2})*\1$ |
Description |
The regex validate a quoted string in VBScript or Ansi SQL. The string may contain the containing quote character if it is escaped by being doubled up.
In VB/VBScript two double quotes within a string enclosed in double qoutes translate into one double quote within the string
In SQL two single quotes within a string enclosed in single qoutes translate into one single quote within the string |
Matches |
"To quote Yoda (""Do, or do not. There is no 'try'"" )" |
Non-Matches |
'This won't validate' | "He said "Ok."" |
Author |
Rating:
Not yet rated.
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
(\[(\w+)\s*(([\w]*)=('|")?([a-zA-Z0-9|:|\/|=|-|.|\?|&]*)(\5)?)*\])([a-zA-Z0-9|:|\/|=|-|.|\?|&|\s]+)(\[\/\2\]) |
Description |
Peseudo-HTML code matcher. Allows for one parameter within the first tag (name is optional), the value of which can be optionally delimited by either double or single quotes. Uses backreferencing to ensure that the end and start tags match, and that any single or double quotes match. Very useful for web forums or any situation where users may be prompted to enter text for display on a webpage somewhere, as it can be quickly processed into HTML without allowing HTML to be specified within the input itself (which may pose a security risk). |
Matches |
[link url="http://www.domain.com/file.extension?getvar=value&secondvar=value"]Link[/li |
Non-Matches |
[a]whatever[/b] | [a var1=something var2=somethingelse]whatever[/a] | [a]whatever[a] |
Author |
Rating:
Not yet rated.
Simon Christensen
|
Displaying page
of
pages;
Items to