63 regular expressions found in this category!
Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
</?(\w+)(\s*\w*\s*=\s*("[^"]*"|'[^']'|[^>]*))*|/?> |
Description |
Matches HTML of XML tags, with or without attributes (single-, double-, or non-quoted), closing tags, or self-closing singleton tags. |
Matches |
<font color="blue"> | </font> | <br /> |
Non-Matches |
this is a test... |
Author |
Rating:
Not yet rated.
Jean-Philip Losier
|
Title |
Test
Details
Pattern Title
|
Expression |
(?'openingTag'<)
\s*?
(?'tagName'\w+)
# Once we've got the tagname, match zero
# or more attribute sequences
(\s*?
# Atomic Grouping for efficiency
(?>
(?!=[\/\?]?>) # Lookahead so that we can fail quickly
# match Attribute pieces
(?'attribName'\w+)
(?:\s*
(?'attribSign'=)
\s*
)
(?'attribValue'
(?:\'[^\']*\'|\"[^\"]*\"|[^ >]+)
)
)
)*
\s*?
# Closing Tag can be either > or />
(?'closeTag'[\/\?]?>) |
Description |
Matches and segments the sections of an opening tag. For more detailed information refer to this blog entry: http://weblogs.asp.net/dneimke/posts/25616.aspx |
Matches |
<head> | <script language=javascript> | <input type=submit > |
Non-Matches |
</head> |
Author |
Rating:
Not yet rated.
Darren Neimke
|
Title |
Test
Details
Pattern Title
|
Expression |
^(#){1}([a-fA-F0-9]){6}$ |
Description |
Matches HTML Color strings. Like #FFFFFF is white and #000000 is black and #FF0000 is red and so on... |
Matches |
#FFFFFF | #FF3421 | #00FF00 |
Non-Matches |
232323 | f#fddee | #fd2 |
Author |
Rating:
Not yet rated.
Mladen Mihajlovic
|
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 |
<!--[\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 |
<[^>]*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 |
<[^>]*\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 |
<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 |
<[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 |
&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]+(\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
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
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 |
(\[(\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
|
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 |
(<meta\s+)*((name\s*=\s*("|')(?<name>[^'("|')]*)("|')){1}|content\s*=\s*("|')(?<content>[^'("|')]*)("|')|scheme\s*=\s*("|')(?<scheme>[^'("|')]*)("|')) |
Description |
Capture the attributes "content", "name" and "scheme" used to parse META tags from any XHTML or HTML input. Useful for developers looking for expresions to parse & get Dublin Core single elements from HTML pages. |
Matches |
<meta name="DC.subject" content="metadata"/> |
Non-Matches |
the other html constructs |
Author |
Rating:
Not yet rated.
Ernesto Giralt
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?<path>(/?(?<step>\w+))+)(?<predicate>\[(?<comparison>\s*(?<lhs>@\w+)\s*(?<operator><=|>=|<>|=|<|>)\s*(?<rhs>('[^']*'|"[^"]*"))\s*(and|or)?)+\])*$ |
Description |
Simple parser of XPath, it doesn't handle the more complex statements but can be of use in some situations. |
Matches |
/root/child1/child2[ @param='value' ] | child1[@param >= "1" and @foo < 'asdf" |
Non-Matches |
/root/*[ local-name() = 'child1' ][ child2/@param='value ]/child2 |
Author |
Rating:
Not yet rated.
Tim Walters
|
Title |
Test
Details
Pattern Title
|
Expression |
(?s)/\*.*\*/ |
Description |
|
Matches |
/* .................... */ | /* imagine lots of lines here */ |
Non-Matches |
*/ malformed opening tag */ | /* malformed closing tag /* |
Author |
Rating:
Not yet rated.
Darren Neimke
|
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 |
^[^<>`~!/@\#}$%:;)(_^{&*=|'+]+$ |
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
|
Displaying page
of
pages;
Items to