Regex problem with urls

I don’t see why my regex is failing. Here is the code:

theRegex = new RegEx
theRegex.Options.DotMatchAll = true
theRegex.Options.Greedy = True
theRegex.SearchPattern = "\b(https?://|www)(\S+)($|<)"
theRegex.ReplacementPattern = "<a href=""\1\2"">\1\2</a>\3"
theRegex.Options.ReplaceAllMatches = True
theText = theRegex.Replace(theText)

The regex is looking for urls in the html and makes clickable links. Why don’t I get the correct result?

1 Like

\S is “no whitespace”, and the “<BR/” qualifies. Try this:


Many thanks!