title: Vbscript Regular expression, find all between 2 known strings
body: <p>I would like to select all texts between two know strings. Say for example the following text</p>
  
  <pre><code>*starthere
  *General Settings 
  *  some text1
  *  some text2
  *endhere
  </code></pre>
  
  <p>I would like to select all texts between "*starthere" and "*endhere" using vbscript. so that the final output looks like the following</p>
  
  <pre><code> *General Settings 
      *  some text1
      *  some text2
  </code></pre>
  
  <p>I know this would be simpler using a regex since there are multiple instances of such pattern in the file i read. </p>
  
  <p>I tried something like the following</p>
  
  <pre><code>/(.*starthere\s+)(.*)(\s+*endhere.*)/
  /(*starthere)(?:[^])*?(*endhere)/
  </code></pre>
  
  <p>But they dont seem to work and it selects even the start and end strings together. Lookforward and backword dont seem to work either and iam not sure if they have support for vbscript.</p>
  
  <p>This is the code I am using:</p>
  
  <pre><code>'Create a regular expression object 
  Dim objRegExp
  Set objRegExp = New RegExp 'Set our pattern
  objRegExp.Pattern = "/\*starthere\s+([\s\S]*?)\s+\*endhere\b/" objRegExp.IgnoreCase = True
  objRegExp.Global = True 
  Do Until objFile.AtEndOfStream 
   strSearchString = objFile.ReadLine
   Dim objMatches
   Set objMatches = objRegExp.Execute(strSearchString)
   If objMatches.Count &gt; 0 Then
    out = out &amp; objMatches(0) &amp;vbCrLf
    WScript.Echo "found"
   End If
  Loop
  WScript.Echo out
  objFile.Close
  </code></pre>