
Originally Posted by
williamsba
We should all just keeping adding to this function until it is the "perfect"
function lol We could even market it out to large firms and sell it for
thousands!!!
Ha Ha Ha
So in fit for that, here's another mod.
Another thing that I thought of & that was left in the previous mod. What if
we wanna target a frame rather than the window attribute. So here's another mod.
Code:
Function LinkURLs(tempTxt, tgt, frm)
'Prefix underscore(_) to tgt if frm=0 or null
If (CInt(frm)=0) OR (CInt(frm)="") Then
tgt = "_" & tgt
End If
'If tgt is blank, set it to self.
If (Trim(tgt)="_") OR (Trim(tgt)="") Then
tgt = "_self"
End If
Dim regEx
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
temptxt = replace(temptxt, "'", "''")
'Hyperlink Email Addresses
regEx.Pattern = "([_.a-z0-9-]+@[_.a-z0-9-]+\.[a-z]{2,3})"
tempTxt = regEx.Replace(tempTxt, "<a href=""mailto:$1"">$1</a>")
'Hyperlink URL's
regEx.Pattern = "((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])"
tempTxt = regEx.Replace(tempTxt, "<a href=""$1"" target=" & tgt & ">$1</a>")
'Make <a href="www = <a href="http://www
tempTxt = Replace(tempTxt, "href=""www", "href=""http://www")
LinkURLs = tempTxt
End Function
Ok NOW, so this function above now also supports targetting frames. Just
another optional parameter added by name of frm. If this parameter is set to
any number but 0, it will not add an underscore(_) to the parameter tgt
which specifies the target name. So if its omitted, then also it will add
underscore(_).
So, if you wanna target a frame, just set frm to any number, better be 1 of
ease of things.
So there!! Any more mods are more than welcome.
Bookmarks