Regular Expression Demo

This examples demonstrates how to surround a certian string with delimiters.


Microsoft has launched a new Web site, www.ASP.NET. This Web site (as you can probably guess) contains information on the next "version" of ASP: ASP.NET. The site contains links to download the latest ASP.NET bits, contains a FAQ section, links to ASP community sites, and other great information. To learn more about ASP.NET, check out www.ASP.NET and the 4Guys ASP.NET Article Index!


<%
  Dim regEx, strText
  Set regEx = New RegExp
  regEx.Global = true
  regEx.IgnoreCase = True

  ' Pattern finds any word (or URL) with
  ' .NET on the end of it
  regEx.Pattern = "(\b[a-zA-Z\._]+?\.NET\b)"

  ' Input a string to test our replace functionality:  
  strText = ""
  strText = strText & "Microsoft has launched a new Web site," & _
                      " www.ASP.NET. " & vbCrLf & "This Web site (as you " & _
                      "can probably guess) contains information " & vbCrLf
  strText = strText & "on the next ""version"" of ASP: ASP.NET. The site " & _
                      "contains links to " & vbCrLf & "download the latest " & _
                      "ASP.NET bits, contains a FAQ section, links " & vbCrLf
  strText = strText & "to ASP community sites, and other great information. " & _
                      "To learn more " & vbCrLf & "about ASP.NET, check out " & _
                      "www.ASP.NET and the 4Guys ASP.NET " & vbCrLf
  strText = strText & "Article Index! " & vbCrLf

  ' Call Replace method of the regular expression: 
  ' the $1 means place the matching text here
  Response.Write regEx.Replace(strText, _
                 "<b style='color: #000099; font-size: 18pt'>$1</b>")

%>


[Return to the Article]