title: RegEx in Classic ASP to find out if the URL has a particular string
body: <p>I have to do a site redirect through script for about 10 different URLS all containing the string "enterpriseloyalty".  I'm trying to write some RegEx to find out if the URL has this in it.  To do so, I'm using a function I found on another question here (<a href="https://stackoverflow.com/questions/6675920/using-classic-asp-for-regular-expression">using classic asp for regular expression</a>).  The problem is that nothing is returning when I test it on the site "<a href="http://enterpriseloyaltyjournal.ca/" rel="nofollow noreferrer">http://enterpriseloyaltyjournal.ca/</a>".</p>
  
  <p>I've tested the regex in both <a href="http://gskinner.com/RegExr/" rel="nofollow noreferrer">http://gskinner.com/RegExr/</a> and <a href="http://www.pagecolumn.com/tool/regtest.htm" rel="nofollow noreferrer">http://www.pagecolumn.com/tool/regtest.htm</a> with matching results of the regex "enterpriseloyalty[A-Za-z]*(?=.{1,1})" working, matching "enterpriseloyaltyjournal" in the URL string.  But on the site, "Response.Write("Results: " &amp; result.Submatches(0))" returns nothing at all.  And to be honest, I don't know if I am expecting a result of the matching string or what, but there's just nothing at all returned.</p>
  
  <p>When I just do an <code>If InStr(Request.ServerVariables("SERVER_NAME"),"enterpriseloyaltyjournal.ca") &gt; 0 Then</code> statement, it comes back true.  My code is below.  Any help is greatly appreciated.</p>
  
  <pre><code>Function RegExResults(strTarget, strPattern)
  
      Set regEx = New RegExp
      regEx.Pattern = strPattern
      regEx.Global = true
      Set RegExResults = regEx.Execute(strTarget)
      Set regEx = Nothing
  
  End Function
  
  'Pass the original string and pattern into the function and get a collection object back'
  Set arrResults = RegExResults(Request.ServerVariables("SERVER_NAME"), "enterpriseloyalty[A-Za-z]*(?=\.{1,1})")
  
  'In your pattern the answer is the first group, so all you need is'
  For each result in arrResults
      Response.Write("Results: " &amp; result.Submatches(0))
  Next
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm also trying the following with no results:</p>
  
  <pre><code>Regex.IgnoreCase = True
  Regex.Pattern = "enterpriseloyalty[A-Za-z]*(?=\.{1,1})"
  Response.Write("Results:" &amp; Regex.Test(Request.ServerVariables("SERVER_NAME")))
  </code></pre>
  
  <p>Also, when I say "no results", I mean nothing at all is returned.  Not even the "Results:" portion.  Though I'm not getting any type of error.</p>
  
  <p><strong>SOLVED</strong></p>
  
  <p>Changed the above code to look like:</p>
  
  <pre><code>Dim regex
  Set regex = New RegExp
  regex.IgnoreCase = True
  regex.Pattern = "enterpriseloyalty[A-Za-z]*(?=\.{1,1})"
  Response.Write("Results:" &amp; regex.Test(Request.ServerVariables("SERVER_NAME")))
  </code></pre>
  
  <p>And it worked just fine.</p>