Regex only retrieves the first necessary element but not all of them
- by Serge
Can anybody help me with retrieving some elements from the following example text:
sdfaasdflj asdfjl;a
AB-12/34 BC-/85 CD-//8 DD-77
DE-78/9
EE-78-98
asdf; asdjf
It is necessary to get the following elements:
AB-12/34, BC-/85, CD-//8, DD-77, DE-78/9
When I'm using a regular expression like this:
\s*(?<elements>\b[A-Z]{2}-[/0-9]+\b)
everything works fine - all the necessary elements are being retrieved (except for the EE element are amonth them, but it doesn't matter).
The problem is that this line is a part of a more complex regex, so when I'm trying to apply a regex like this:
(?s).*\sas.*?
\s*(?<elements>\b[A-Z]{2}-[/0-9]+\b)*.*
.*as
It only returns me just the first AB-12/34 element and nothing else.
How to correct the regex to get all the elements? TIA.