I have a text line matching this pattern \d{2}\s?[a-zA-Z]\s?\d{2,5} zero to many times.
That pattern will match char sequences which can be described as following: two digits, followed by one letter and two to five digits. the letter may be separated by exactly one blank, but that´s optional.
Such a sequence can occur every where in the text, together with words and numbers but also solely.
I need to remove everything but the matching sequence in pure regex substitution (not using java loops, streams etc)
Examples:
"foo 12a123" --> "12a123"
"12a123 bar" --> "12a123"
"foo 12a123 bar 32A1234 baz" --> "12a123 32A1234"
"12 a123 bar 32A 1234" --> "12 a123 32A 1234"
"foo bar" (no match) --> ""
Any ideas?
"foo 12a123 bar 32A1234 baz"-->"12a123 32A1234", not -->"12a12332A1234". Isn't that slightly different?"12a12345b456 foo"or in"12a123bar"?