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: 44 regular expressions found.

Change page:   |    Displaying page 1 of 3 pages; Items 1 to 20
Title Test Details Pattern Title
Expression
</?(\w+)(\s+\w+=(\w+|"[^"]*"|'[^']*'))*>
Description
Finds any HTML tag and sub-matches properties weather it has an apposterphee, quote, or no quote/apposterphee
Matches
<TD> | <TD bgColor="FFFFFF"> | </TD>
Non-Matches
No Tag Here ...
Author Rating: The rating for this expression. 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
>(?:(?<t>[^<]*))
Description
Detects HTML tags open and/or closed with and without whitespace or characters in between. Good for stripping all tags from a string.
Matches
<b> | </b> | <p><b>some text</b></p>
Non-Matches
<
Author Rating: Not yet rated. Jonathan Crossland
Title Test Details Pattern Title
Expression
<[a-zA-Z]+(\s+[a-zA-Z]+\s*=\s*("([^"]*)"|'([^']*)'))*\s*/>
Description
Matches a valid &quot;empty&quot; tag (has trailing slash). Note, if you run it against a string such as &lt;img src=&quot;test.gif&quot; alt=&quot;&lt;hr /&gt;&quot;&gt; it will indeed return a match. But, the match is not at character 1 like you'd suspect, but rather it's matching the internal &lt;hr /&gt;. If you look at the source of this tag (http://concepts.waetech.com/unclosed_tags/) you'll find a whoe suite of regex's for matching html tags. Using them you could feasibly step though a document and avoid this mismatch as the outer tag would match *in totality* and you'd completely skip this inner match.
Matches
<img src="test.gif"/>
Non-Matches
<img src="test.gif"> | <img src="test.gif"a/>
Author Rating: Not yet rated. Joshua Olson
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
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
&lt;a[a-zA-Z0-9 =&quot;'.:;?]*(name=){1}[a-zA-Z0-9 =&quot;'.:;?]*\s*((/&gt;)|(&gt;[a-zA-Z0-9 =&quot;'&lt;&gt;.:;?]*&lt;/a&gt;))
Description
This expression matches only valid html anchors. Those are anchors with an attribute name=. Such anchor can be closed either with &lt;/a&gt; or with /&gt;. If someone can help - one thing still missing is not matching html tags with parameter href, becazse such should be considered as non valid anchors.
Matches
&lt;a name=&quot;anchorName&quot;&gt;Anchor&lt;/a&gt; | &lt;a name=anchorName /&gt;
Non-Matches
&lt;a href=&quot;somewhere&quot;&gt; | &lt;a href&gt; | &lt;a name /&gt;
Author Rating: The rating for this expression. Aleš Potocnik
Title Test Details Pattern Title
Expression
(?<TAG>\s*<(?<TAG_NAME>\w*)\s+(?<PARAMETERS>(?<PARAMETER>(?<PARAMETER_NAME>\w*)(=["']?)(?<VALUE>[\w\W\d]*?)["']?)+)\s*/?>)
Description
Parse html tags to extract tag names and parameters with parameter name/value pairs.
Matches
<td valign="top" align="left" colspan="2">
Non-Matches
<!--dynamic_content GlobalID=49113-->
Author Rating: The rating for this expression. Maxim Paukov
Title Test Details Pattern Title
Expression
<a[a-zA-Z0-9 ="'.:;?]*(href=[\"\'](http:\/\/|\.\/|\/)?\w+(\.\w+)*(\/\w+(\.\w+)?)*(\/|\?\w*=\w*(&\w*=\w*)*)?[\"\'])*(>[a-zA-Z0-9 ="'<>.:;?]*</a>)
Description
i've merged two regular expression those i found on this site. thanks to the owners &quot;Aleš Potocnik and Andrew Lee &quot;. i used their expression to make mine. this expression finds the URL/Hyperlink with the HTML tags.
Matches
<a href="http://www.google.co.in/hi">Hindi</a>
Non-Matches
href="http://www.google.co.in/hi"
Author Rating: Not yet rated. himraj love
Title Test Details Self Close Valid HTML Tags
Expression
<(?<!\\?|\\/)([^>]*)>\\r*\\n<\\/(?=br|hr|img|input|link|param)[^>]*>
Description
This pattern searches for tags in HTML that should be self closing but currently aren't and self closes them. This is useful if you are doing some HTML parsing.
Matches
<br> CRLF </br> etc.
Non-Matches
<textarea> CRLF </textarea> etc.
Author Rating: Not yet rated. Iain Dooley
Title Test Details replace html tags with valid xhtml
Expression
(<input )(.*?)(>)
Description
Finds all &lt;input attrib1="value1" attrib2="value2" ... &gt; tags. You can make it end with "/&gt;" for xhtml compatibility replacing with the expression "&lt;input $2 /&gt;". You can repeat it with other tags like &lt;img /&gt; or &lt;br / &gt;
Matches
&lt;input attrib1="value1" attrib2="value2" &gt;
Non-Matches
any other tag
Author Rating: Not yet rated. Mauricio Venanzoni
Title Test Details Img Src Attribute
Expression
src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?
Description
This pattern matches an image url attribute of an img html tag. It searches for the src attribute and grabs the value as a grouped match - "imgSrc".
Matches
src="http://www.thoughtlava.com/images/logo.gif" | src='http://www.thoughtlava.com/images/logo.gif' | src=http://www.thoughtlava.com/images/logo.gif
Non-Matches
src="http://www.thoughtlava.com/images/logo.wmf"
Author Rating: Not yet rated. Steven Pena
Title Test Details Find <h1> Tags
Expression
<h([1-6])>([^<]*)</h([1-6])>
Description
This regex find valid <h1-6> html tags
Matches
<h2>test2</h2><h3>test3</h3>
Non-Matches
<h>test1</h>
Author Rating: The rating for this expression. Syrprize
Title Test Details HTML Anchor tag
Expression
<a\s+(?:(?:\w+\s*=\s*)(?:\w+|"[^"]*"|'[^']*'))*?\s*href\s*=\s*(?<url>\w+|"[^"]*"|'[^']*')(?:(?:\s+\w+\s*=\s*)(?:\w+|"[^"]*"|'[^']*'))*?>[^<]+</a>
Description
This will match an entire HTML tag and will capture the href portion into the named capture "url". It will match any anchor tag with any number of attributes.
Matches
The entire &lt;a href=""&gt;&lt;/a&gt; tag
Non-Matches
Links that include any html within the tag.
Author Rating: The rating for this expression. Derek Pinkerton
Title Test Details Does string have HTML in it?
Expression
[\w*|\W*]*<[[\w*|\W*]*|/[\w*|\W*]]>[\w*|\W*]*
Description
This will match true if the string contians at least one HTML tag.
Matches
This containt &lt;HTML&gt; tags. &lt;B&gt; Bold! &lt;/B&gt;
Non-Matches
This text does not contain HTML.
Author Rating: The rating for this expression. Chris Pietschmann
Title Test Details HREF
Expression
(?<=<(\S|\s)*)((?<=(href=('|")+))|(?<=(href=))[^('|")])([^'>"\s)]*)(?=('|"|[\S])?)
Description
This will pull the HREF values out of any HTML tag in a query and present only the HREF values. It's very versatile, it can accept a number of nonstandard formats.
Matches
HTML HREF values -- &lt;a href=dir/file.php> & &lt;a href="http://www.google.com" target="_blank"> & &lt;a target="_blank" href="otherfile.php">
Non-Matches
Plaintext or non HREF VALUES
Author Rating: The rating for this expression. arbitar
Title Test Details ISIN number between ><
Expression
(?<=>)[A-Z]{2}[\d|\w]{9}\d{1}(?=(<))
Description
ISIN must be located inside a html tag eg. <td>JP3756600007</td>. Just remove the (..) at the beginning and the end if you wish to match all ISINs.
Matches
>JP3756600007< without brackets
Non-Matches
JP3756600007
Author Rating: Not yet rated. MT
Title Test Details List HTML tags
Expression
<(?![!/]?[ABIU][>\s])[^>]*>
Description
Used to return all the html tags and closing tags in a section of html. Can be used to replace all the tags with nothing or itterate through them.
Matches
<u><b>hello</b></u>
Non-Matches
hello
Author Rating: Not yet rated. Richard Brisley
Title Test Details Remove (X)HTML like tags
Expression
<\s*?[^>]+\s*?>
Description
This simple pattern is useful for removing all HTML tags with or without atributes. It has no removing white spaces
Matches
< html > | < div style="title_1" class='number'> | < div style="title_1" class='number' > | < img src="img.gif" / >
Non-Matches
Plain text
Author Rating: The rating for this expression. Shreeve
Change page:   |    Displaying page 1 of 3 pages; Items 1 to 20

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