So I am trying to get the token that starts with a 3.
The AAXX line below is picking it up right. However, doing some edge cases, the wrong 3 token is getting picked up in the BBXX line. The difference is that in BBXX line, the 3 group appears after a 222\d{2} token.
This 222\d{2} 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.
So basically, want the optional token that begins with 3 that either appears before 222\d{2} if it exists, or before the end of the line if it doesn't.
I don't know if that requires a negative look behind, or just how to exclude a match that would start with 222\d{2}.
https://regex101.com/r/MOgfl8/1
Thanks.
 
     
    