title: REGEX: Exclude matches after a specific string
body: <p>So I am trying to get the token that starts with a <code>3</code>.</p>
  <p>The <code>AAXX</code> line below is picking it up right. However, doing some edge cases, the wrong 3 token is getting picked up in the <code>BBXX</code> line. The difference is that in <code>BBXX</code> line, the 3 group appears after a <code>222\d{2}</code> token.</p>
  <p>This <code>222\d{2}</code> token is optional. I will only want the 3 token that appears before it, never after it. And even then, the 3 token is optional and might not appear.</p>
  <p>So basically, want the optional token that begins with <code>3</code> that either appears before <code>222\d{2}</code> if it exists, or before the end of the line if it doesn't.</p>
  <p>I don't know if that requires a negative look behind, or just how to exclude a match that would start with <code>222\d{2}</code>.</p>
  <p><a href="https://regex101.com/r/MOgfl8/1" rel="nofollow noreferrer">https://regex101.com/r/MOgfl8/1</a></p>
  <p>Thanks.</p>