I need to capture multiple groups of the same pattern. Suppose, I have a following string:
HELLO,THERE,WORLD
And I've written a following pattern
^(?:([A-Z]+),?)+$
What I want it to do is, capture every single word, so that Group 1 is : "HELLO", Group 2 is "THERE" and Group 3 is "WORLD" What my regex is actually capturing only the last one, which is "WORLD".
I'm testing my regular expression here and I want to use it with Swift (maybe there's a way in Swift to get intermediate results somehow, so that I can use them?)
UPDATE: I don't want to use split
. I just need to now how to capture all the groups that have matched the pattern, not only the last one.
,
? – rock321987 May 3 '16 at 12:04[A-Z]+
or[^,]+
to capture the results – rock321987 May 3 '16 at 12:07