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

   Displaying page 1 of 1 pages; Items 1 to 8
Title Test Details Pattern to find Anchor Tag in a web page
Expression
<a[\s]+[^>]*?href[\s]?=[\s\"\']*(.*?)[\"\']*.*?>([^<]+|.*?)?<\/a>
Description
This pattern is a slight modification in pattern submitted by Jacek Sompel. Using this tag one can also match anchor tags not having ' (single quote) or " (double quote) in href. This is useful for web crawler for crawling all links in a web page.
Matches
&lt;a href='http://www.regexlib.com'&gt;Text&lt;/a&gt; | &lt;a href="..."&gt;Text&lt;/a&gt; | &lt;a href=http://www.regexlib.com&gt;Text&lt;/a&gt;
Non-Matches
all other html tags
Author Rating: The rating for this expression. Kuleen Upadhyaya
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 Hyperlink attributes
Expression
(?s)(?<=<a[^>]+?)(?<name>\w+)=(?:["']?(?<value>[^"'>]*)["']?)(?=.+?>)
Description
Captures all attributes in HTML anchor tags, putting them into groups named "name" and "value"
Matches
<a class='foo' href="http://regexplib.com">
Non-Matches
<p align="center">&nbsp;</p>
Author Rating: Not yet rated. Kevin Spencer
Title Test Details Title Anchor Tags
Expression
<a((?:(?! title=)[^">]*"[^">]*")+)>([^<]+)<\/a>
Description
Use the above pattern with this replacement pattern: "<a\1 title="\2">\2</a>" and it will put title tags in all of your anchors that don't have a title tag.
Matches
&lt;a href="/"&gt;Home&lt;/a&gt; | &lt;a href="/" style="font-size: 30px"&gt;Home&lt;/a&gt;
Non-Matches
&lt;a href="/"&gt;&lt;span style="font-size: 30px"&gt;Home&lt;/span&gt;&lt;/a&gt;
Author Rating: Not yet rated. Kerry Jones
Title Test Details Match unanchored urls in unstructured text
Expression
\b((?<!["'>])(?:https?://)?(?<![-@>])(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])\.)+(?:com|org|net|gov|mil|biz|info|name|aero|mobi|jobs|museum|[A-Z]{2})(?:/[-A-Z0-9\/_.]+)?(?:\?[-A-Z0-9&\._%=,]+)?(?!['"<]))\b
Description
Use this regex to match urls (including folder, file and querystring) in unstructured text that are not in anchor tags. Replace with <a href="$1">$1</a> to create anchor tags.
Matches
www.shschools.org/community/ethics_conference.html?s=keyword
Non-Matches
<a href="www.shschools.org/community/ethics_conference.html?s=keyword">www.shschools.org/community/ethics_conference.html?s=keyword</a>
Author Rating: Not yet rated. Bob Clark
Title Test Details Strip HTML tags with exceptions
Expression
<\/*?(?![^>]*?\b(?:a|img)\b)[^>]*?>
Description
This regex will match all HTML tags except 'a' tags or 'img' tags. You can edit the list of exclusions as you see fit. I use this regex to strip all HTML tags from source data except anchor tags and image tags.
Matches
<script> </html> <anytag>
Non-Matches
<a> <img /> </a>
Author Rating: The rating for this expression. Charles Forsyth
Title Test Details Anchor Tag, href, title and innerHTML (PHP)
Expression
#<a\s*(?:href=[\'"]([^\'"]+)[\'"])?\s*(?:title=[\'"]([^\'"]+)[\'"])?.*?>((?:(?!</a>).)*)</a>#i
Description
Returns array of full A tag [0], href [1], title [2] and innerHTML [3]. href, title and innerHTML are optional in tag; will return empty if missing. Test will only work using PHP preg_match_all or similar; I ask this site to add that option. Credit goes to user prometheuzz.
Matches
<a id='a' class=''b' href='c' title='d'>innerHTML</a>; <a></a>
Non-Matches
non a tags
Author Rating: The rating for this expression. Jeff Flesher
Title Test Details Anchor tags title
Expression
<a[\s](?!.*\b(title)\b)[^>]+>
Description
Finding all the anchor tags that do not contain the title attribute
Matches
Non-Matches
This working well with all my files
Author Rating: Not yet rated. Theo
   Displaying page 1 of 1 pages; Items 1 to 8

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