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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
<a\s*.*?href\s*=\s*['"](?!http:\/\/).*?>(.*?)<\/a>
Description
Finds all local links, but doesnt match on external links. Use replace with $1 to leave the link text but remove the link.
Matches
<a href='locallink.htm'>my local link</a> | <a title='click here' href="/a/local
Non-Matches
<a href='http://www.site.com/page.htm'>www.site.com</a> | <a href='http://www.site.co
Author Rating: Not yet rated. james mountain
Source peter lushpay (lushpay.com)
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Incorrectly stops at <a href="/local>foo"> before foo
Name: Randal L. Schwartz
Date: 3/9/2005 10:20:25 AM
Comment:
Do not parse HTML with regex. It's a complex problem. Use a real HTML parser.


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