Trouble executing the regexp

Results 1 to 3 of 3

Thread: Trouble executing the regexp

  1. #1
    Nalin Mittal Guest

    Default Trouble executing the regexp

    I grabbed the following function from Microsofts VB reference page:<BR><BR>Function RegExpTest(patrn, strng)<BR> Dim regEx, Match, Matches1 &#039; Create variable.<BR> Set regEx = New RegExp &#039; Create regular expression.<BR> regEx.Pattern = patrn &#039; Set pattern.<BR> regEx.IgnoreCase = True &#039; Set case insensitivity.<BR> regEx.Global = True &#039; Set global applicability.<BR> Set Matches1 = regEx.Execute(strng) &#039; Execute search.<BR> For Each Match in Matches1 &#039; Iterate Matches collection.<BR> RetStr = RetStr & "Match found at position "<BR> RetStr = RetStr & Match.FirstIndex & ". Match Value is &#039;"<BR> RetStr = RetStr & Match.Value & "&#039;." & vbCRLF <BR> Next<BR> RegExpTest = RetStr<BR>End Function<BR><BR>I always get the following error:<BR>Server object error &#039;ASP 0177 : 800a139a&#039; <BR>Server.CreateObject Failed <BR>/regexp.asp, line 25 <BR>The operation completed successfully. <BR><BR>This error complains about the following line of code:<BR>Set Matches1 = regEx.Execute(strng) &#039; Execute search.<BR><BR>For some reason whenever I try to grab the collection of matches, I get an error.<BR>Any help is greatly appreciated.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Trouble executing the regexp

    First thing I would suggest is making sure you have VBScript version 5.0 or above on the server. RegExp wasn&#039;t supported before then.<BR><BR>To do that, use the following:<BR>&#060;%=ScriptEngine%&#062;<BR>&#060 ;%=ScriptEngineMajorVersion%&#062;<BR>&#060;%=Scri ptEngineMinorVersion%&#062;<BR><BR>Hope that helps.

  3. #3
    Join Date
    Dec 1969

    Default RE: Trouble executing the regexp

    What is the value of strng and patrn? Do:<BR><BR>Response.Write "Patrn = " & patrn & "<BR>Strng = " & strng<BR><BR>and let us know what the output is. Also, what version of the VBScript scripting engine are you using?

Posting Permissions

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