Does anyone know how to trim the $1 value?
' URL Replacement, www.Scirra.com
Dim objRegExp : set objRegExp = new RegExp
With objRegExp
.Pattern = "\[url\](.*)\[\/url]"
.IgnoreCase = True
.Global = True
End With
strMessage = objRegExp.replace(strMessage, "<a href=""$1"" rel=""nofollow"">$1</a>")
set objRegExp = nothing
Example, if I enter:
[url] http://www.scirra.com[/url]
This renders as an unclickable link because of the %20 before it. What I’d like to do is something like:
strMessage = objRegExp.replace(strMessage, "<a href=""" & trim($1) & """ rel=""nofollow"">" & trim($1) & "</a>")
Surround your capturing group with
\s*and, while you’re at it, change the pattern to avoid using.*(you want to capture everything but a[or a space — use a complemented character class):(note: not sure the
[needs escaping in the character class)