RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Browse Expressions by Category

63 regular expressions found in this category!

Expressions in category: Markup/Code

Change page:   |    Displaying page 1 of 4 pages; Items 1 to 20
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: The rating for this expression. Chris Craft
Title Test Details Pattern Title
Expression
[0][x][0-9a-fA-F]+
Description
Matches hexadecimal values like in c-sourcecode exists.
Matches
0x0ffe
Non-Matches
x0ffe
Author Rating: The rating for this expression. Andreas Schiller
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
&quote; | © | '
Non-Matches
& | &#Hello; | &#Xray;
Author Rating: The rating for this expression. 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: The rating for this expression. 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: The rating for this expression. 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: The rating for this expression. Gabriel Fróes
Title Test Details Pattern Title
Expression
&lt;(\/{0,1})img(.*?)(\/{0,1})\&gt;
Description
This regular expression allows you to match all image tags
Matches
&lt;img src=&quot;immy.jpg&quot; alt=&quot;Image&quot;&gt; | &lt;img src=&quot;immy.jpg&quot; alt=&q
Non-Matches
&lt; img &gt;
Author Rating: The rating for this expression. Alessandro Pellegrini
Title Test Details Pattern Title
Expression
<[^>]*>
Description
HTML Pattern Matching PLEASE HELP /&lt;[^&gt;]*&gt;/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 &lt;input type=button value=test onclick='if(n.value&gt;5)do_this();'&gt;. 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 &gt; within a '' or &quot;&quot;. &lt;input type=button onclick='if(n.value&gt;5)do_this();'&gt; not this &lt;br&gt; &lt;input type=button onclick=&quot;n&gt;5?a():b();&quot; value=test&gt; not this &lt;br&gt; &lt;input type=button onclick=&quot;n&gt;5?a(\&quot;OK\&quot;):b('Not Ok');&quot; value=test&gt; not this &lt;br&gt; &lt;input type=button onclick='n&gt;5' value=test onmouseover=&quot;n&lt;5&amp;&amp;n&gt;8&quot; onmouseout='if(n&gt;5)alert(\'True\');else alert(&quot;False&quot;)'&gt; not this &lt;br&gt; Any help would be greatly appreciate. Thanks a whole lot. Logan
Matches
<html>
Non-Matches
abc
Author Rating: The rating for this expression. Logan Tran
Title Test Details Pattern Title
Expression
(?s)( class=\w+(?=([^&lt;]*&gt;)))|(&lt;!--\[if.*?&lt;!\[endif\]--&gt;)|(&lt;!\[if !\w+\]&gt;)|(&lt;!\[endif\]&gt;)|(&lt;o:p&gt;[^&lt;]*&lt;/o:p&gt;)|(&lt;span[^&gt;]*&gt;)|(&lt;/span&gt;)|(font-family:[^&gt;]*[;'])|(font-size:[^&gt;]*[;'])(?-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, &quot;&quot;).
Matches
&lt;span&gt;
Non-Matches
&lt;table&gt;
Author Rating: The rating for this expression. Peter Donker
Title Test Details Pattern Title
Expression
href[ ]*=[ ]*('|\&quot;)([^\&quot;'])*('|\&quot;)
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(&quot;/href[ ]*=[ ]*('|\&quot;)([^\&quot;'])*('|\&quot;)/&quot;,$string,$matches)
Matches
href=&quot;index.php&quot; | href = 'http://www.dailymedication.com' | href = &quot;irc://irc.junk
Non-Matches
href=http://www.dailymedication.com
Author Rating: The rating for this expression. 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: The rating for this expression. Darren Neimke
Title Test Details Pattern Title
Expression
&lt;!--[\s\S]*?--[ \t\n\r]*&gt;
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 &gt;
Matches
&lt;!-- anything -- &gt; | &lt;!-- anything -&gt; -&gt; --&gt;
Non-Matches
&lt;!-- something -- and more &gt;
Author Rating: The rating for this expression. Kristijan Mitrovic
Title Test Details Pattern Title
Expression
\xA9
Description
Matches the copyright symbol (&amp;copy;). Pretty simple, yet I dont think existed on RegExLib before.
Matches
©
Non-Matches
anything
Author Rating: The rating for this expression. Roman Lukyanenko
Title Test Details Pattern Title
Expression
&quot;([^&quot;](?:\\.|[^\\&quot;]*)*)&quot;
Description
Matches C style strings allowing for escaped string delimiters to be included in the match. ALTERED 13-Dec-2003 ------------------- Previous pattern was : &quot;([^&quot;](?:\\.|[^\\&quot;]*)*)&quot; Changed to: &quot;([^&quot;]*(?:\\.|[^\\&quot;]*)*)&quot; Making the first character after the opening quote optional allows the pattern to match on empty quotes: &quot;&quot;.
Matches
&quot;This is a \&quot;string\&quot;.&quot;
Non-Matches
&quot;This is a \&quot;string\&quot;.
Author Rating: The rating for this expression. Darren Neimke
Title Test Details Pattern Title
Expression
&lt;!--.*?--&gt;
Description
Matches
&lt;!-- &lt;h1&gt;this text has been removed&lt;/h1&gt; --&gt; | &lt;!-- yada --&gt;
Non-Matches
&lt;h1&gt;this text has not been removed&lt;/h1&gt;
Author Rating: The rating for this expression. 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 &lt;a&gt; 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: The rating for this expression. Andrew Lee
Title Test Details Pattern Title
Expression
("[^"]*")|('[^\r]*)(\r\n)?
Description
Will match a VBScript string and/or comment Ex: ' userinfo strUsername = &quot;tomsve&quot; iAge = 20 ' temp strPassword = &quot;halloj&quot; ...Would result in the following matches: ' userinfo &quot;tomsve&quot; ' temp &quot;halloj&quot; Good luck! Tom S. [email protected]
Matches
"my string" | "a string with ' in it" | ' comment
Non-Matches
asd "
Author Rating: The rating for this expression. 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: The rating for this expression. 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: The rating for this expression. 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 &quot;c&quot; format strings for printf/scanf functions.
Matches
%s%02d | %s | %04lX
Non-Matches
%5.f | %++X | %@d
Author Rating: The rating for this expression. Vladimir Klykov
Change page:   |    Displaying page 1 of 4 pages; Items 1 to 20

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials