I have what seems to be a simple task but isn't working for me. Using only PCRE2 Regex (nothing else), I am trying to collect a phrase before the first colon at the beginning of a line, then separate and place within the same group all the comma separated values.
Here are some sample texts:
Shapes: circle, rectangle, triangle
Junk line: this part, here, should work, but: make sure, that last colon, isn't caught
Should be captured as such:
Group 1:
Shapes:
Group 2:
circle
rectangle
triangle
Group 1:
Junk line:
Group 2:
this part
here
should work
but: make sure
that last colon
isn't caught
I know comma separated values can be captured many ways, like this:
([^,]+)
But if I try to add anything to the beginning, the match stops after the first comma, so this:
(.*):([^,]+)
Will not work (plus it captures the second colon in a line anyway). Any help is appreciated!
EDITED TO ADD: The matching should stop at the end of the line, so something like this:
One: two, three
Yellow: Blue, Green
Should not catch Yellow as part of two, three. Yellow should be caught as a new instance of group one