63 regular expressions found in this category!
Displaying page
of
pages;
Items to
| Title |
Test
Details
HTML 4.01 Elements
|
| Expression |
(<\/?)(?i:(?<element>a(bbr|cronym|ddress|pplet|rea)?|b(ase(font)?|do|ig|lockquote|ody|r|utton)?|c(aption|enter|ite|(o(de|l(group)?)))|d(d|el|fn|i(r|v)|l|t)|em|f(ieldset|o(nt|rm)|rame(set)?)|h([1-6]|ead|r|tml)|i(frame|mg|n(put|s)|sindex)?|kbd|l(abel|egend|i(nk)?)|m(ap|e(nu|ta))|no(frames|script)|o(bject|l|pt(group|ion))|p(aram|re)?|q|s(amp|cript|elect|mall|pan|t(r(ike|ong)|yle)|u(b|p))|t(able|body|d|extarea|foot|h|itle|r|t)|u(l)?|var))(\s(?<attr>.+?))*> |
| Description |
This RE will match all the valid elements in HTML 4.01 |
| Matches |
<HTML> | <a href="link.html">Link</a> |
| Non-Matches |
<xml> | <phonytag> | <image> |
| Author |
Rating:
Michael Ash
|
| Title |
Test
Details
(X)HTML click events
|
| Expression |
(?i:on(blur|c(hange|lick)|dblclick|focus|keypress|(key|mouse)(down|up)|(un)?load|mouse(move|o(ut|ver))|reset|s(elect|ubmit))) |
| Description |
This regex will match all the valid on event attributes in HTML 4.01/XHTML 1.0 |
| Matches |
onclick | onsubmit | onmouseover |
| Non-Matches |
click | onandon | mickeymouse |
| Author |
Rating:
Michael Ash
|
| 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:
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:
Simon Christensen
|
| 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:
Darren Neimke
|
| Title |
Test
Details
Pattern Title
|
| Expression |
<!--.*?--> |
| Description |
|
| Matches |
<!-- <h1>this text has been removed</h1> --> | <!-- yada --> |
| Non-Matches |
<h1>this text has not been removed</h1> |
| Author |
Rating:
Tony Austin
|
| 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:
Brenden Salta
|
| Title |
Test
Details
Pattern Title
|
| Expression |
<!--[\s\S]*?--[ \t\n\r]*> |
| Description |
As I could understand the HTML standard, this is the valid reg.exp. for comments.
The only differenc from the last one is that the comment can be terminated by two minuses followed by none OR SOME space caracters and then by character > |
| Matches |
<!-- anything -- > | <!-- anything -> -> --> |
| Non-Matches |
<!-- something -- and more > |
| Author |
Rating:
Kristijan Mitrovic
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(SELECT\s[\w\*\)\(\,\s]+\sFROM\s[\w]+)|
(UPDATE\s[\w]+\sSET\s[\w\,\'\=]+)|
(INSERT\sINTO\s[\d\w]+[\s\w\d\)\(\,]*\sVALUES\s\([\d\w\'\,\)]+)|
(DELETE\sFROM\s[\d\w\'\=]+) |
| Description |
This RE match the SQL Basics Queries (SELECT, UPDATE, INSERT and DELETE). |
| Matches |
SELECT * FROM TABLE | UPDATE TABLE SET FIELD=VALUE WHERE ID_FIELD=VALUE_ID | DELETE FROM TABLE WHERE |
| Non-Matches |
SELECT TABLE | UPDATE SET TABLE | INSERT INTO FIELD=VALUE TABLE |
| Author |
Rating:
Gabriel Fróes
|
| Title |
Test
Details
Pattern Title
|
| Expression |
\{\\\*\\bkmkstart\s(.*?)\} |
| Description |
Applied to a .RTF document, returns all the names of the# bookmarks. Useful to retrieve# dinamically# the list of bookmarks from a document. |
| Matches |
{\*\bkmkstart TagAmountDigits} | ({\*\bkmkstart TagAmountText} |
| Non-Matches |
{\*\bkmkend TagAmountText} |
| Author |
Rating:
Fernando Eklipse
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(?<commentblock>((?m:^[\t ]*\/{2}[^\n\r\v\f]+[\n\r\v\f]*){2,})|(\/\*[\w\W]*?\*\/)) |
| Description |
This expression will match comment blocks in javascript, c, c++, etc
I wrote this as a named group called "commentblock", as I like to use it with other expressions.
It avoids single line comments or inline commented code (which are not considered comment "blocks") unless the comments are in a /* text */ comment style
could not create a multiline example in the matching examples, here is what I tried to enter
// Some text
//(must be two or more lines long and each line may only be preceded by whitespace)
|
| Matches |
/* Some text (may be any number of lines) */ |
| Non-Matches |
// Some text (only a single line) | Some code // comment here (even if next line has comment) | /* S |
| Author |
Rating:
Chris Strolia-Davis
|
| 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:
Frederick Samson
|
| 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:
Michael Ash
|
| Title |
Test
Details
Enitity notation
|
| Expression |
&
(?ni:\# # if a pound sign follow ampsand look for number
((x # if x follow pound sign accept hex value up to 5 digits
([\dA-F]){1,5}
)
| # otherwise accept decimal number between 0 - 1048575
(104857[0-5]
|10485[0-6]\d
|1048[0-4]\d\d
|104[0-7]\d{3}
|10[0-3]\d{4}
|0?\d{1,6})
)
| # no pound sign after ampersand
([A-Za-z\d.]{2,31}) #accept ASCII alphanumeric and period
); #end with semi-colon. |
| Description |
This regex can be used to find general entites in HTML, XML and SGML files.
The entity can consist of
1) an ampsand (&)
2) followed by
(a) ASCII alphanumerics or period between 2 and 31 characters or
(b) a pound sign #
(i) followed by an x followed by a unicode value up to 5 hex digits or
(ii) followed by a decimal value from 0 to 1048575
3) ending with a semi-colon (;) |
| Matches |
"e; | © | ' |
| Non-Matches |
& | &#Hello; | &#Xray; |
| Author |
Rating:
Michael Ash
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$ |
| Description |
Tests for valid HTML hexadecimal color codes. The # symbol is optional. And it will except either the 3 digit form for the 216 Web safe colors, or the full 6 digit form. I am use it on my site to allow users to customize the site's colors. |
| Matches |
#00ccff | #039 | ffffcc |
| Non-Matches |
blue | 0x000000 | #ff000 |
| Author |
Rating:
Chris Craft
|
| 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:
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:
Lewis Moten
|
| 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 |
('.*$|Rem((\t| ).*$|$)|"(.|"")*?") |
| Description |
Pulls out comments (both Rem and ') and string literals from VB or VBScript. Usefull for spell checking or review.
Notes: The VBScript for "Rem" documentation says that it must be followed by a space but VBScript seems to accept tab characters as well.
The multiline flag is assumed for this search. |
| Matches |
' This is a comment | Rem This is a comment | " This is a string with "" and ' " |
| Non-Matches |
" This is not a string | RemThis is not a comment | This is not a comment or a string |
| Author |
Rating:
Ed Preston
|
| Title |
Test
Details
Pattern Title
|
| Expression |
href=[\"\'](http:\/\/|\.\/|\/)?\w+(\.\w+)*(\/\w+(\.\w+)?)*(\/|\?\w*=\w*(&\w*=\w*)*)?[\"\'] |
| Description |
I wrote up this regular expression to fetch the href attribute found in <a> tags as well as a few other HTML tags. |
| Matches |
href="www.yahoo.com" | href="http://localhost/blah/" | href="eek" |
| Non-Matches |
href="" | href=eek | href="bad example" |
| Author |
Rating:
Andrew Lee
|
Displaying page
of
pages;
Items to