I've got a Regex question, I have to recognize tokens in a text that are like:
Foo-
followed by either bar
or baz
followed by -
then some numbers, like:
Foo-bar-010
Foo-baz-101
I then want to divide my matches like : Foo-bar
-010
and Foo-baz
-101
My regex is this one:
(Foo-(bar|baz))-[0-9]+
Which is kinda cool, but I don't want to define a group for the 'bar' or 'baz' clause, since it messes my results.
Any idea to get this result with only one group?
(Foo-\b(?:bar|baz)\b)-[0-9]+
?: usually flags the group as a non-capturing match (depending on your engine).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With