I am trying to extract a section of text that looks something like this:
Thing 2A blah blah Thing 2A blah blah Thing 3
Where the “3” above could actually be ANY single digit. The code I have that doesn’t work is:
((Thing\s2A).+?(Thing\s\d))
Since the 3 could be any single digit, I cannot simply replace the “\d” with “3”. I tried the following code, but it doesn’t work either:
((Thing\s2A).+?(Thing\s\d[^A]))
Please help!
Is this what you’re trying to do?
((Thing\s2A).+?(Thing\s[0-9]))Edit: Oh I get it, you want a digit not followed by an A. Use a forward lookahead
((Thing\s2A).+?(Thing\s[0-9](?!A))That’s assuming you want it not followed by an A. Replace the A with whatever you DON’T want to follow the digit
((Thing\s2A).+?(Thing\s[0-9](?![A-Za-Z]))Or if you know what you expect after the digit, you can add it. For example
((Thing\s2A).+?(Thing\s[0-9][\s$])That will match Thing 3 followed by a space, tab, or a newline