开发者

Regex to match links that arent already marked up

I want to match any URL that isn't already enclosed in an href. i.e I want to ignore the following.

<a href="http://www.test.com/whatever">

I'm trying to write a regex to automatically find urls, so that I can turn them into marked up a hrefs.

The issue I'm having is dealing with urls that have already开发者_运维问答 been marked up (The documents contain a mix of marked up and not marked up urls).


Use negative look ahead to see if an url does NOT have </a> ahead of it

your_regex(?!\s*</a>)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜