RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details Pattern Title
Expression
(\s|\n|^)(\w+://[^\s\n]+)
Description
will match free floating valid protocol + urls in text ... will not touch the ones wrapped in a tag, so that you can auto-link the ones that aren't :) couple of things to know : 1. if the url is next to a tag this won't work (eg : <br>http://www.acme.com), the url must either start with a \s, \n or any character other than >. 2. the pattern will match the preceding \s and \n too, so when you replace put them back in place $1 will either be \s or \n, $2 will be the exact match vb usage : set re = New RegExp re.Pattern ="(\s|\n|^)(\w+://[^\s\n]+)" strResult = re.Replace(strText, "$1<a href='$2' target='_new'>$2</a>")
Matches
http://www.acme.com | ftp://ftp.acme.com/hede | gopher://asdfasd.asdfasdf
Non-Matches
<a href="http://acme.com">http://www.acme.com</a> | <br>http://www.acme.
Author Rating: The rating for this expression. ic onur
   Displaying page 1 of 1 pages; Items 1 to 1

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials