63 regular expressions found in this category!
Displaying page
of
pages;
Items to
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
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
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
Pattern Title
|
Expression |
/\*[\d\D]*?\*/ |
Description |
If you need to extract or remove any /* */ sytle comments from any Java, JavaScript, C, C++, CSS, etc code you have this regular expression can help. |
Matches |
/* my comment */ | /* my multiline comment */ | /* my nested comment */ |
Non-Matches |
*/ anything here /* | anything between 2 seperate comments | \* *\ |
Author |
Rating:
Chris Craft
|
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 |
<(\/{0,1})img(.*?)(\/{0,1})\> |
Description |
This regular expression allows you to match all image tags |
Matches |
<img src="immy.jpg" alt="Image"> | <img src="immy.jpg" alt=&q |
Non-Matches |
< img > |
Author |
Rating:
Alessandro Pellegrini
|
Title |
Test
Details
Pattern Title
|
Expression |
<[^>]*> |
Description |
HTML Pattern Matching
PLEASE HELP
/<[^>]*>/ig
The above pattern is only successful when html tag are simple (they don't include any javascript). This mean that the pattern will fail if something like this is within the tag <input type=button value=test onclick='if(n.value>5)do_this();'>. It will not match the entire open n close sign.
How do you write a pattern that will pass all these tag so that the pattern will match from the open to the close sign and not when it just see a > within a '' or "".
<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>
Any help would be greatly appreciate. Thanks a whole lot.
Logan |
Matches |
<html> |
Non-Matches |
abc |
Author |
Rating:
Logan Tran
|
Title |
Test
Details
Pattern Title
|
Expression |
(?s)( class=\w+(?=([^<]*>)))|(<!--\[if.*?<!\[endif\]-->)|(<!\[if !\w+\]>)|(<!\[endif\]>)|(<o:p>[^<]*</o:p>)|(<span[^>]*>)|(</span>)|(font-family:[^>]*[;'])|(font-size:[^>]*[;'])(?-s) |
Description |
Word HTML cleanup code. Use this expression to get rid of most of the stuff that Word adds to an HTML document such as: lots of span elements, font-family and font-size style attributes, class attributes, a whole bunch of if-then statements. Use this expression in a regex.replace(originalHtml, regExpr, "").
|
Matches |
<span> |
Non-Matches |
<table> |
Author |
Rating:
Peter Donker
|
Title |
Test
Details
Pattern Title
|
Expression |
href[ ]*=[ ]*('|\")([^\"'])*('|\") |
Description |
the regex's on this site for pulling links off a page always seemed to be faulty, or at least never worked with PHP, so i made this one. simple, as i'm an amateur with regex's, but stumbled thru it and this one actually works. tested with PHP function: preg_match_all("/href[ ]*=[ ]*('|\")([^\"'])*('|\")/",$string,$matches) |
Matches |
href="index.php" | href = 'http://www.dailymedication.com' | href = "irc://irc.junk |
Non-Matches |
href=http://www.dailymedication.com |
Author |
Rating:
Jason Paschal
|
Title |
Test
Details
Pattern Title
|
Expression |
(?'DateLiteral' (?# Per the VB Spec : DateLiteral ::= '#' [ Whitespace+ ] DateOrTime [ Whitespace+ ] '#' )
\#\s*
(?'DateOrTime' (?# DateOrTime ::= DateValue Whitespace+ TimeValue | DateValue | TimeValue )
(?'DateValue'
(?# DateValue ::= Whitespace+ TimeValue | DateValue | TimeValue )
(
(?# DateValue ::= MonthValue / DayValue / YearValue | MonthValue - DayValue - YearValue )
(?'Month'(0?[1-9])|1[0-2]) (?# Month 01 - 12 )
(?'Sep'[-/]) (?# Date separator '-' or '/' )
(?'Day'0?[1-9]|[12]\d|3[01]) (?# Day 01 - 31 )
\k'Sep' (?# whatever date separator was previously matched )
(?'Year'\d{1,4})
\s+
(?# TimeValue ::= HourValue : MinuteValue [ : SecondValue ] [ WhiteSpace+ ] [ AMPM ] )
(?'HourValue'(0?[1-9])|1[0-9]|2[0-4]) (?# Hour 01 - 24 )
[:]
(?'MinuteValue'0?[1-9]|[1-5]\d|60) (?# Minute 01 - 60 )
[:]
(?'SecondValue':0?[1-9]|[1-5]\d|60)? (?# Optional Minute :01 - :60 )
\s*
(?'AMPM'[AP]M)?
)
|
(
(?# DateValue ::= MonthValue / DayValue / YearValue | MonthValue - DayValue - YearValue )
(?'Month'(0?[1-9])|1[0-2]) (?# Month 01 - 12 )
(?'Sep'[-/]) (?# Date separator '-' or '/' )
(?'Day'0?[1-9]|[12]\d|3[01]) (?# Month 01 - 31 )
\k'Sep' (?# whatever date separator was previously matched )
(?'Year'\d{4})
)
|
(
(?# TimeValue ::= HourValue : MinuteValue [ : SecondValue ] [ WhiteSpace+ ] [ AMPM ] )
(?'HourValue'(0?[1-9])|1[0-9]|2[0-4]) (?# Hour 01 - 24 )
[:]
(?'MinuteValue'0?[1-9]|[1-5]\d|60) (?# Minute 01 - 60 )
[:]
(?'SecondValue':0?[1-9]|[1-5]\d|60)? (?# Optional Minute :01 - :60 )
\s*
(?'AMPM'[AP]M)?
)
)
)
\s*\#
) |
Description |
Match the VB Language specification BNF for DateTime literal. http://msdn.microsoft.com/library/en-us/vbls7/html/vblrfvbspec2_4_6.asp?frame=true
DateLiteral ::= # [ Whitespace+ ] DateOrTime [ Whitespace+ ] #
DateOrTime ::=
DateValue Whitespace+ TimeValue |
DateValue |
TimeValue
DateValue ::=
MonthValue / DayValue / YearValue |
MonthValue – DayValue - YearValue
TimeValue ::=
HourValue : MinuteValue [ : SecondValue ] [ WhiteSpace+ ] [ AMPM ]
MonthValue ::= IntLiteral
DayValue ::= IntLiteral
YearValue ::= IntLiteral
HourValue ::= IntLiteral
MinuteValue ::= IntLiteral
SecondValue ::= IntLiteral
AMPM ::= AM | PM
|
Matches |
# 8/23/1970 3:45:39AM # | # 8/23/1970 # |
Non-Matches |
## | # 23/8/1970 # |
Author |
Rating:
Darren Neimke
|
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 |
\xA9 |
Description |
Matches the copyright symbol (&copy;). Pretty simple, yet I dont think existed on RegExLib before. |
Matches |
© |
Non-Matches |
anything |
Author |
Rating:
Roman Lukyanenko
|
Title |
Test
Details
Pattern Title
|
Expression |
"([^"](?:\\.|[^\\"]*)*)" |
Description |
Matches C style strings allowing for escaped string delimiters to be included in the match.
ALTERED 13-Dec-2003
-------------------
Previous pattern was :
"([^"](?:\\.|[^\\"]*)*)"
Changed to:
"([^"]*(?:\\.|[^\\"]*)*)"
Making the first character after the opening quote optional allows the pattern to match on empty quotes: "". |
Matches |
"This is a \"string\"." |
Non-Matches |
"This is a \"string\". |
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 |
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
|
Title |
Test
Details
Pattern Title
|
Expression |
("[^"]*")|('[^\r]*)(\r\n)? |
Description |
Will match a VBScript string and/or comment
Ex:
' userinfo
strUsername = "tomsve"
iAge = 20
' temp
strPassword = "halloj"
...Would result in the following matches:
' userinfo
"tomsve"
' temp
"halloj"
Good luck!
Tom S. [email protected] |
Matches |
"my string" | "a string with ' in it" | ' comment |
Non-Matches |
asd " |
Author |
Rating:
Tom Svensson
|
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
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 |
%[\-\+0\s\#]{0,1}(\d+){0,1}(\.\d+){0,1}[hlI]{0,1}[cCdiouxXeEfgGnpsS]{1} |
Description |
This regular expression matches "c" format strings for printf/scanf functions. |
Matches |
%s%02d | %s | %04lX |
Non-Matches |
%5.f | %++X | %@d |
Author |
Rating:
Vladimir Klykov
|
Displaying page
of
pages;
Items to