Challenge-code problem parsing email

Results 1 to 2 of 2

Thread: Challenge-code problem parsing email

  1. #1
    Join Date
    Dec 1969

    Default Challenge-code problem parsing email

    Thank you for reading this.<BR>I&#039;m using the following code to look for a pattern of an email address. There is a problem with the subroutine when I&#039;m using regular expressions. If I call the subroutine like this RegExpTest "is.", "Is1 is2 is3 is4" then it works fine and returns all occurrences of is. However, if I call the subroutine like this RegExpTest "^([w-.]+)@(([([0-9]{1,3}.){3}[0-9]{1,3}])&#124(([w-]+.)+)([a-zA-Z]{2,4}))$", " your mama" this doesn&#039;t return anything. If I change the second parameter to "" it does return this match. If I change it to " and" it does not return a match. Can someone help me with figuring out why?<BR><BR>Sub RegExpTest(strMatchPattern, strPhrase)<BR> &#039;create variables<BR> Dim objRegEx, Match, Matches, StrReturnStr<BR> &#039;create instance of RegExp object<BR> Set objRegEx = New RegExp <BR><BR> &#039;find all matches<BR> objRegEx.Global = True<BR> &#039;set case insensitive<BR> objRegEx.IgnoreCase = True<BR> &#039;set the pattern<BR> objRegEx.Pattern = strMatchPattern <BR><BR> &#039;create the collection of matches<BR> Set Matches = objRegEx.Execute(strPhrase) <BR><BR> &#039;print out all matches<BR> For Each Match in Matches<BR> strReturnStr = "Match found at position "<BR> strReturnStr = strReturnStr & Match.FirstIndex & ". Match Value is &#039;"<BR> strReturnStr = strReturnStr & Match.value & "&#039;."<BR> &#039;print<BR> Response.Write(strReturnStr & "<BR>")<BR> Next<BR>End Sub

  2. #2
    Join Date
    Dec 1969

    Default RE: Challenge-code problem parsing email

    You&#039;ve specified in your pattern the beggining character "^" and ending character "$". You need to remove those if you want to find 0 or more occurances in your string. Use those characters when you want to match the entire string one time.

Posting Permissions

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