
["1,0,0,0","","","","","","","","","","","","","","","","","", "","","","","","","","","","",""]
ie the right answer, and 28 other empty answers.
The documentation says
"Note that there may be more components in the returned list than were in the pattern, and that any component which either matched the empty string or wasn't matched at all (because it was part of an optional part of the pattern), will be empty."
Does this mean I had 28 matches with the empty string?
No, it means there are more components in the returned list than in your original pattern, and you should ignore the extra ones. This is because GNU regex doesn't tell us how many components are actually returned, as I recall.
Why are they returned? Will I always have to filter all these null strings out of every result? Will the result I want always be first?
Yes, no(*), and yes. (*) don't filter out the null strings, just strip the extra ones from the tail of the returned list. Remember that some of the components may legitimately be empty, for example if one of the components in your pattern was optional (eg. "a(bc)?d"). Cheers, Simon
participants (1)
-
Simon Marlow