Skip to content


Need clarification/confirmation of Nil handling in ?-quantifiers #35

pmichaud opened this Issue · 2 comments

4 participants


Just wanting to make sure we cover the bases on ?-quantifiers...

Consider an expression like:

'1a2b345e' ~~ / [ (\d) (<[a..z]>)? ]+ /

Clearly $0 and $1 will both be lists of Match objects because of the indirect + quantifier, and $0 will have five elements.

Will $1 end up with three elements (the Match objects for 'a', 'b', and 'e'),
five elements (Match for 'a', Match for 'b', Nil, Nil, and Match for 'e'),
or some other result?



Match, Match, Nil, Nil, Match is the best, seems to me. Also note that Nil is not supposed to turn into () in list context anymore, so @$0 Z @$1 should stay in sync.


If you have something like:

'1a-2b-3-4-5e' ~~ / [ (\d) (<[a..z]>)? ]+ % '-' /

It would be hard to loop over $0 and $1 at the same time if $1 had not the same number of elements...

So, +1 for Nil

@timo timo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.