Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts

    Question about regExp

    I found this code on the internet and I really don't know how this regExp works.
    What're the $1$2$3 numbers on the code to convert to anchors?
    If someone could explain me at least some of the code that would be great!
    Thanks!

    Code:
    Function ReplaceRegExp(strString, strPattern, strReplace)
    
    	Dim RE: Set RE = New RegExp
    
    	With RE
    		.Pattern = strPattern
    		.Global = True
    		ReplaceRegExp = .Replace(strString, strReplace)
    	End With
    	
    End Function
    Code:
    Function BBCodeToHTML(strString)
    	strString = ReplaceRegExp(strString, "(http|ftp|https)(:\/\/[\w\-_]+)((\.[\w\-_]+)+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?", "<a href=""$1$2$3$5"" target=""_blank"">$1$2$3$5</a>")
    ...

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    My RegExp is lousy, as I'm sure my previous posts will testify, but I THINK that the brackets in the regexp itself break matches into discrete sub-matches which can then be referenced via the dollar notation. Does that make sense?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •