<p>I have a load of user-submitted content. It is HTML, and may contain URLs. Some of them will be <code>&lt;a&gt;</code>'s already (if the user is good) but sometimes users are lazy and just type www.something.com or at best <a href="http://www.something.com" rel="noreferrer">http://www.something.com</a>.</p>

<p>I can't find a decent regex to capture URLs but ignore ones that are immediately to the right of either a double quote or '>'. Anyone got one?</p>

Jan Goyvaerts, creator of
RegexBuddy
, has
written a response
to Jeff Atwood's blog that addresses the issues Jeff had and provides a nice solution.
```
```
\b(?:(?:https?|ftp|file)://|www\.|ftp\.)[-A-Z0-9+&@#/%=~_|$?!:,.]*[A-Z0-9+&@#/%=~_|$]
```
```
In order to ignore matches that occur right next to a " or >, you could add
```
(?<![">])
```
to the start of the regex, so you get
```
```
(?<![">])\b(?:(?:https?|ftp|file)://|www\.|ftp\.)[-A-Z0-9+&@#/%=~_|$?!:,.]*[A-Z0-9+&@#/%=~_|$]
```
```
This will match full addresses (
http://..
.) and addresses that start with www. or ftp. - you're out of luck with addresses like ars.userfriendly.org...