Displaying page
of
pages;
Items to
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 |
<a href='http://www.regexlib.com'>Text</a> | <a href="...">Text</a> | <a href=http://www.regexlib.com>Text</a> |
Non-Matches |
all other html tags |
Author |
Rating:
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 <a href=""></a> tag |
Non-Matches |
Links that include any html within the tag. |
Author |
Rating:
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"> </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 |
<a href="/">Home</a> | <a href="/" style="font-size: 30px">Home</a> |
Non-Matches |
<a href="/"><span style="font-size: 30px">Home</span></a> |
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:
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:
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
of
pages;
Items to