Reputation: 9541
How can I alter this regex to not match mailto links?
(href|src)\=\"([^(http)])(\/)?
Should match
<a href="myurl">
Should not match
<a href="http://myurl">
<a href="mailto://myurl">
Upvotes: 2
Views: 1413
Reputation: 5064
Use following one its working :
((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+)
Here you can test it : http://regexlib.com/RETester.aspx?regexp_id=37
Upvotes: 0
Reputation: 121
As suggested, try using Negative-lookahead.
This could give you a head-start:
(href|src)\=\"(?!(http|mailto))(\/)?
Upvotes: 0
Reputation: 9541
Just in case someone else comes across this question, I changed it like this
(href|src)\=\"(?!http|mailto)(\/)?
Upvotes: 3
Reputation: 538
Use a negative lookahead to dismiss urls with mailto
http://www.regular-expressions.info/lookaround.html
Upvotes: 0