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

Please support RegExLib Sponsors

Sponsors

Advanced Search

Keywords

Category

Minimum Rating

Results per Page

Search Results: 224 regular expressions found.

Change page:   |    Displaying page 1 of 12 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
\[link="(?<link>((.|\n)*?))"\](?<text>((.|\n)*?))\[\/link\]
Description
This can be used in conjunction with the replace method to provide pseudo-code support without having to enable HTML. The replacement string (in ASP.NET, use RegExp.Replace(SourceString, RegularExpressionPattern, ReplacementString) is &lt;a href=&quot;${link}&quot;&gt;${text}&lt;/a&gt;.
Matches
[link="http://www.yahoo.com"]Yahoo[/link]
Non-Matches
[link]http://www.yahoo.com[/link] | [link=http://www.yahoo.com]Yahoo[/link]
Author Rating: Not yet rated. Ryan S
Title Test Details Pattern Title
Expression
^\d{9}[\d|X]$
Description
A very simple ISBN validation expression - it just checks for a 10 digit number where the last digit could also be a capital 'X'. Complete specs for ISBN available here: http://www.isbn.org/standards/home/isbn/international/html/usm4.htm. An enhancement would be to allow exactly 3 or 0 hyphens or 3 or 0 spaces, since these are also valid formats.
Matches
1234123412 | 123412341X
Non-Matches
not an isbn
Author Rating: Not yet rated. Steven Smith
Title Test Details Pattern Title
Expression
&lt;[^&gt;]*\n?.*=(&quot;|')?(.*\.jpg)(&quot;|')?.*\n?[^&lt;]*&gt;
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
&lt;td background=&quot;../img/img.jpg&quot; &gt; | &lt;img src=img.jpg &gt; | &lt;img src='img.jpg'
Non-Matches
= img.jpg | img.jpg
Author Rating: Not yet rated. Marc-Antoine Latour
Title Test Details Pattern Title
Expression
&lt;[^&gt;]*name[\s]*=[\s]*&quot;?[^\w_]*&quot;?[^&gt;]*&gt;
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
&lt;input type = text name = &quot;bob&quot;&gt; | &lt;select name = &quot;fred&quot;&gt; | &lt;form
Non-Matches
&lt;input type = submit&gt; | &lt;font face = &quot;arial&quot;&gt; | The drity brown fox stank like
Author Rating: Not yet rated. Andrew Freese
Title Test Details Pattern Title
Expression
&lt;[^&gt;\s]*\bauthor\b[^&gt;]*&gt;
Description
This expression will match the corresponding XML/HTML elements opening and closing tags. Useful to handle documents fragments, without loading an XML DOM.
Matches
&lt;author name=&quot;Daniel&quot;&gt; | &lt;/sch:author&gt; | &lt;pp:author name=&quot;Daniel&quot;
Non-Matches
&lt;other&gt; | &lt;/authors&gt; | &lt;work&gt;author&lt;/work&gt;
Author Rating: Not yet rated. Daniel Cazzulino
Title Test Details Pattern Title
Expression
<img([^>]*[^/])>
Description
Use this along with this replacement string &lt;img\1 /&gt; to convert image tags to XHTML compliant image tags.
Matches
<img src="bob">
Non-Matches
<img src="bob" />
Author Rating: The rating for this expression. Murray Roke
Title Test Details Pattern Title
Expression
&lt;!--[\s\S]*?--&gt;
Description
Removes pesky comments and commented javascript from HTML
Matches
&lt;!-- comments --&gt; | &lt;!-- x = a &gt; b - 3 --&gt;
Non-Matches
&lt;COMMENTS&gt;this is a comment&lt;/COMMENTS&gt;
Author Rating: Not yet rated. Lewis Moten
Title Test Details Pattern Title
Expression
&lt;/?(\w+)(\s+\w+=(\w+|&quot;[^&quot;]*&quot;|'[^']*'))*&gt;
Description
Finds any HTML tag and sub-matches properties weather it has an apposterphee, quote, or no quote/apposterphee
Matches
&lt;TD&gt; | &lt;TD bgColor=&quot;FFFFFF&quot;&gt; | &lt;/TD&gt;
Non-Matches
No Tag Here ...
Author Rating: The rating for this expression. Lewis Moten
Title Test Details Pattern Title
Expression
&amp;lt;/?([a-zA-Z][-A-Za-z\d\.]{0,71})(\s+(\S+)(\s*=\s*([-\w\.]{1,1024}|&amp;quot;[^&amp;quot;]{0,1024}&amp;quot;|'[^']{0,1024}'))?)*\s*&amp;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
&amp;lt;IMG src='stars.gif' alt=&amp;quot;space&amp;quot; height=1&amp;gt;
Non-Matches
this is not a tag
Author Rating: Not yet rated. Lewis Moten
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\s+href\s*=\s*&quot;http:\/\/([^&quot;]*)&quot;([^&gt;]*)&gt;(.*?(?=&lt;\/a&gt;))&lt;\/a&gt;$
Description
Regexp to find all external links in a HTML string. Can easily be modified to handle all/other links/protocols (like file/https/ftp). Uses lookahead assertions and non-greedy modifier to check for the end &lt;/a&gt; but still allow html tags inbetween start and end A tag. Takes into account that there could be linebreaks and other nasty whitespace chars in the middle of the tag. I am using it to find all external links in embedded HTML code and change 1.the target of the link 2.insert a &quot;Leaving Site&quot; logo to illustrate you are leaving site.
Matches
&lt;a href=&quot;http://www.mysite.com&quot;&gt;my external link&lt;/a&gt; | &lt;a href=&quot;http:/
Non-Matches
&lt;a href=&quot;myinternalpage.html&quot;&gt;my internal link&lt;/a&gt;
Author Rating: Not yet rated. Anders Rask
Title Test Details Pattern Title
Expression
&lt;/?(\w+)(\s*\w*\s*=\s*(&quot;[^&quot;]*&quot;|'[^']'|[^&gt;]*))*|/?&gt;
Description
Matches HTML of XML tags, with or without attributes (single-, double-, or non-quoted), closing tags, or self-closing singleton tags.
Matches
&lt;font color=&quot;blue&quot;&gt; | &lt;/font&gt; | &lt;br /&gt;
Non-Matches
this is a test...
Author Rating: Not yet rated. Jean-Philip Losier
Title Test Details Pattern Title
Expression
&lt;[aA][ ]{0,}([a-zA-Z0-9&quot;'_,.:;!?@$&amp;()%=/ ]|[-]|[ \f]){0,}&gt;((&lt;(([a-zA-Z0-9&quot;'_,.:;!?@$&amp;()%=/ ]|[-]|[ \f]){0,})&gt;([a-zA-Z0-9&quot;'_,.:;!?@$&amp;()%=/ ]|[-]|[ \f]){0,})|(([a-zA-Z0-9&quot;'_,.:;!?@$&amp;()%=/ ]|[-]|[ \f]){0,})){0,}
Description
I wrote this sweet little (well, not so little really) reg to extract links from an HTML source.... it is very robust, give it a try. The only limitation I have discovered is that it can't match invalid HTML...
Matches
&lt;a href='javascript:functionA();'&gt;&lt;i&gt;this text is italicized&lt;/i&gt;&lt;/a&gt;
Non-Matches
&lt;A href='#'&gt;&lt;P&lt;/A&gt;&lt;/P&gt;
Author Rating: Not yet rated. Brian Webb
Title Test Details Pattern Title
Expression
^[0-9A-Za-z_ ]+(.[jJ][pP][gG]|.[gG][iI][fF])$
Description
Matches HTML image leaf filenames.
Matches
good.gif | go d.GIf | goo_d.jPg
Non-Matches
junk | bad.bad.gif | slash\gif.
Author Rating: Not yet rated. Geoffrey Swenson
Title Test Details Pattern Title
Expression
<script[^>]*>[\w|\t|\r|\W]*</script>
Description
this pattern can find all lines of script in HTML code from open to close tag range
Matches
<script language=javascript>document.write("one");</script>
Non-Matches
--
Author Rating: The rating for this expression. Bassel Issa
Title Test Details Pattern Title
Expression
&lt;[^&gt;]+&gt;
Description
This expression finds all opening and closing tags. Good for stripping out tags in an XML or HTML document. I used it to clean-up HTML documents that had XML mixed in. It found all the tags, then I just deleted the ones that weren't standard. I used it in HOMESITES extended find.
Matches
&lt;html&gt; | &lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt; | &lt;
Non-Matches
Any plain old text | http://www.regexlib.com/Add.aspx | xml&gt;
Author Rating: The rating for this expression. X Man
Title Test Details Pattern Title
Expression
^[0-9]{1,}(,[0-9]+){0,}$
Description
It could be use to validate html input form (checkbox, optionbox, selectbox) when you have multiple numeric value under one field name. The validation is that the user have at lease chose one or more!
Matches
1111 | 47,26,2,1,1111,12 | 25,1245,2122,23232
Non-Matches
111, | 1a1,111,1212,23 | 11aa,aaa,asas,asa
Author Rating: The rating for this expression. Nicholas Rathwell
Title Test Details Pattern Title
Expression
&lt;[iI][mM][gG]([^&gt;]*[^/&gt;])
Description
simple little RegExp to get the IMG tag from HTML
Matches
&lt;img src=&quot;abc.jpg&quot;&gt; | &lt;img src=&quot;abc.jpg&quot;/&gt; | &lt;ImG src=&quot;abc.j
Non-Matches
none
Author Rating: Not yet rated. Asim Goheer
Title Test Details Pattern Title
Expression
\b(((\S+)?)(@|mailto\:|(news|(ht|f)tp(s?))\://)\S+)\b
Description
Whilst writing a plain-text to HTML function, I ran into the problem of links that users had written with &amp;lt;a&amp;gt; tags (as opposed to just writing the URL) were linking improperly. This regular expression returns many types of URL, and preceding characters, if any. This allows you to handle each type of match appropriately
Matches
href='http://www.deepart.org' | [email protected] | ftp://123.123.123.123
Non-Matches
www.deepart.org | deepart.org | 123.123.123.123
Author Rating: Not yet rated. Demo Gorgon
Change page:   |    Displaying page 1 of 12 pages; Items 1 to 20

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