Given strings that look like one of the two following
"Stop Blasting to Move Track, Continue Blasting 95E10 FF"
"Continue Blasting I.D. on Exchanger 95HE03A"
how can I used ruby regex to extract item numbers 95E10 and 95HE03A respectively?
CodePudding user response:
Try the following regex:
\d [A-Z] \d [A-Z]*
Explanation
The \d
's match the numbers on either side of the string. [A-Z]
in the middle matches the letters in the middle, whilst the [A-Z]*
matches zero or more letters at the end.
CodePudding user response:
Use regex:
\d (([A-Z] )?(\d )?)*