title: VBA regular expression using lookahead
body: <p>Given a string like the following:</p>
  
  <blockquote>
    <p>"First there is a sentence or two, then a citation which I'd like to
    extract. Bookwriter, Johnny J., <em>Book Title</em>, 50th Edition, Publishing
    Company, United States, 2016, p. 18."</p>
  </blockquote>
  
  <p>Using this regular expression:<code>"\b[^\.\;]+(,\s+p+\.\s+(\d+\-\d+|\d+))"</code></p>
  
  <p>I'm able to match this portion of the string:</p>
  
  <blockquote>
    <p>"<em>Book Title</em>, 50th Edition, Publishing Company, United States, 2016,
    p. 18"</p>
  </blockquote>
  
  <p>My desired match is:</p>
  
  <blockquote>
    <p>"Bookwriter, Johnny J., <em>Book Title</em>, 50th Edition, Publishing
    Company, United States, 2016, p. 18"</p>
  </blockquote>
  
  <p>To oversimplify it a bit, the current regex finds strings between a period and a page reference like ", p. 18" that doesn't have a semicolon or period in it.</p>
  
  <p>I'd like to adjust this such that the regex permits a period to occur if it is preceded by a space and a capital letter. I'm aware that <a href="https://stackoverflow.com/questions/9150552/lookbehind-on-regex-for-vba">vba doesn't have lookbehind functionality</a>.</p>
  
  <p>The VBA code to run the example I've given is as follows:</p>
  
  <pre><code>Dim exampleString As String
  exampleString = "First there is a sentence or two, then a citation which I'd like to extract. Bookwriter, Johnny J., Book Title, 50th Edition, Publishing Company, United States, 2016, p. 18."
  Set re = CreateObject("vbscript.regexp")
  With re
      .Global = True
      .pattern = "\b[^\.\;]+(,\s+p\.\s(\d+\-\d+|\d+))"
      Set matches = .Execute(exampleString)
  End With
  </code></pre>