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
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 |
(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\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 |
<!--.*?--> |
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 |
(?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 |
\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 |
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 |
(?'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 |
"([^"](?:\\.|[^\\"]*)*)" |
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 |
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
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
(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 |
src[^>]*[^/].(?:jpg|bmp|gif)(?:\"|\') |
Description |
This expression will return the src (source) property of an image tag <IMG>. The source returned is limited to the file extensions supplied. It doesn't matter if the image is prefixed with '../' or 'http://..blah' or 'drive\path' or nothing. This expression could be modifed to return other sources or for the tags (ie <BGSOUND>, <SCRIPT>, etc.) depending on the file extensions given.
I needed this to replace the source of images in a HTML page when I wanted to save the page to a local drive and keep the images intact.
If anybody could modify this further to include only the <IMG> tag, I would appreciate the effort. |
Matches |
src="../images/image.jpg" | src="http://domain.com/images/image.jpg" | src='d:\w |
Non-Matches |
src="../images/image.tif" | src="cid:value" |
Author |
Rating:
Lloyd Sturge
|
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 |
<\*?font # Match start of Font Tag
(?(?=[^>]+color.*>) #IF/THEN lookahead color in tag
(.*?color\s*?[=|:]\s*?) # IF found THEN move ahead
('+\#*?[\w\s]*'+ # CAPTURE ColorName/Hex
|"+\#*?[\w\s]*"+ # single or double
|\#*\w*\b) # or no quotes
.*?> # & move to end of tag
|.*?> # ELSE move to end of Tag
) # Close the If/Then lookahead
# Use Multiline and IgnoreCase
# Replace the matches from RE with MatchEvaluator below:
# if m.Groups(1).Value<>"" then
# Return "<font color=" & m.Groups(1).Value & ">"
# else
# Return "<font>"
# end if |
Description |
This RE and MatchEvaluator will remove everything from inside HTML font tags EXCEPT the color declaration. (For ex: allow users to upload HTML content to site without their font tags overridding the font styles set in the CSS, except for the ability to change the font color for special emphasis.)
This works with color declarations using single quotes, double quotes, no quotes, color-names (red, black), Hex colors (#669933), and inline Style declarations inside a font tag. Does not work with inline Style declarations inside other tags like DIV, SPAN, or P (although it could be expanded to include those as well). |
Matches |
<font size=5 color=black face=Arial> | <font style="font-family:arial;color:red"& |
Non-Matches |
<DIV style="font-family:arial;color:red"> | <SPAN style="color:red"> |
Author |
Rating:
Not yet rated.
Cheri Verdend
|
Title |
Test
Details
Pattern Title
|
Expression |
(?i:)(?<=\.)\D\D(?:-\D{2,3}?(?:-\D\D\D\D)?)?(?=.resx)
#Just change the extension if you want to take a Culture out of different type of file name.
#The result will always be of the format:
#(2CharacterLanguage)-(2or3CharacterLocale)-(4CharacterScript)
#where the second or third set are optional
#this matches the format of the CultureInfo object in Microsoft .NET |
Description |
This expression pulls the Culture name out of a .resx file name. |
Matches |
blah.is.en.resx | something.zh-CHS.resx | something.uz-UZ-Cyrl.resx |
Non-Matches |
blah.is.eee.resx | something.zh-X.resx | something.uz-UZ-Uz.resx |
Author |
Rating:
Not yet rated.
Eric Falsken
|
Displaying page
of
pages;
Items to