Reputation: 1721
I have couple of strings
Staten Island\31R722
Manhattan\03M185
Queens\24Q058
where I would like to isolate and output two digits after \
Output for
Staten Island\31R722
should be 31
Manhattan\03M185
should be 03
Queens\24Q058
should be 24
This is the regex I have so far
\w+\s*\w+\\
I'm not sure how to eliminate the single letter and three characters after it.
It is always a single letter and three characters.
Upvotes: 2
Views: 2334
Reputation: 67968
^\w+(?:\s+\w+)?\\|[A-Z].*$
You can use this and replace by empty string
.See demo.
https://regex101.com/r/rX1tE6/5
Upvotes: 3