Needle in haystack: Specific string followed by exact set of numbers
How can I search for ABC????
where ABC should be exactly that, but the ???? must be exactly four numbers, ideally followed by whitespace.
Illustrative examples:
LHRJFKABC1234 233
<-- Has needleEABC123 LHRJFK
<-- Does not have needle as only 3 numbers following ABC
Something tells me I need to search for string something like (\d{4})
for the 4 numbers. But not sure quite how to puzzle it all together.
What I've found so far:
- Regular expression to match standard 10 digit phone number
- Regular Expression to match specific string followed by number?
CodePudding user response:
For things like this I find an online checker like Rubular very handy.
Unless I'm misunderstanding, the regex ABC\d{4}\s
should work for you. Do you need groupings (i.e. to match the 4-digit part)?
Try it out on Rubular here