Regular Expressions Buffer

Results 1 to 2 of 2

Thread: Regular Expressions Buffer

  1. #1
    Willard Guest

    Default Regular Expressions Buffer

    RegExpressions - backreferences<BR>I am trying to use backreferences to break down the parts of a URL. Microsoft has a pretty simple intro to this on their site(included below). ***MY QUESTION*** regards how to access the backreferences. I am a beginner, so forgive me if I am asking a really dumb question, but I am trying to use the following to without success --any ideas?:<BR><BR><BR>&#060;%<BR>dim strURL, re<BR>strURL = "Set"&#062;"<BR>Set re = New regexp<BR>re.Pattern = "(w+)://([^/:]+)(:d*)?([^# ]*)"<BR>re.Global = True<BR>re.IgnoreCase = True<BR>Response.Write re.$1<BR>Response.Write re.$2<BR>Response.Write re.$3<BR>Response.Write re.$4<BR>%&#062;<BR><BR>---------------------------------------------------------<BR>Exerpt from <BR><BR><BR>Another way that backreferences can be used is to break down a Universal Resource Indicator (URI) into its component parts. Assume that you want to break down the following URI down to the protocol (ftp, http, etc), the domain address, and the page/path:<BR><BR><BR>The following regular expressions provides that functionality. For JScript:<BR><BR>/(w+)://([^/:]+)(:d*)?([^# ]*)/<BR>For VBScript:<BR><BR>"(w+)://([^/:]+)(:d*)?([^# ]*)"<BR>The first parenthetical subexpression is designed to capture the protocol part of the web address. That subexpression matches any word that precedes a colon and two forward slashes. The second parenthetical subexpression captures the domain address part of the address. That subexpression matches any sequence of characters that does not include &#039^&#039, &#039/&#039, or &#039:&#039 characters. The third parenthetical subexpression captures a website port number, if one is specified. That subexpression matches zero or more digits following a colon. And finally, the fourth parenthetical subexpression captures the path andor page information specified by the web address. That subexpression matches one or more characters other than &#039#&#039 or the space character.<BR><BR>Applying the regular expression to the URI shown above, the submatches contain the following:<BR><BR>RegExp.$1 contains "http"<BR>RegExp.$2 contains ""<BR>RegExp.$3 contains ":80"<BR>RegExp.$4 contains "/scripting/default.htm"

  2. #2
    Richard A. Lowe Guest

    Default RE: Regular Expressions Buffer

    Yes, you never execute the re on the string you&#039re checking. Put in re.execute(strURL) after re.IgnoreCase = True<BR><BR>Richard

Posting Permissions

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