Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

ASP.NET / VB / REGEX: Automatically Parse http and https Links

Using ASP.NET and VP and REGEX, how can I make links beginning with http:// and https:// HTML links?

http://example.info
should become
<a href="http://example.info">http://example.info</a>

I would like the code below to be modified:

input = RegularExpressions.Regex.Replace(input, VbNewLine, VbNewLine +"<br />")
input = RegularExpressions.Regex.Replace(input, "(\www\.\S+[^\s@,.""']+)", "<a href=""http://$1"">$1</a>")
input = RegularExpressions.Regex.Replace(input, "([^\s@,.""']+\@\S+\.[^\s@,.""']+)", "<a href=""mailto:$1"">$1</a>")
input = RegularExpressions.Regex.Replace(input, "  ", " &nbsp;")
return input

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Carl Bohman
Carl Bohman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial