Skip to content

Interaction of :pos with :g (and :ov and :ex) in match #16

pmichaud opened this Issue Jul 7, 2012 · 3 comments

2 participants

Perl 6 member
pmichaud commented Jul 7, 2012

What should be the result of the following...?

say 'abcd'.match( /./, :pos(1), :global);

Should it:
1. return only the one match that is anchored at position 1,
2. return all matches, anchoring only the first one, or
3. return the match anchored at position 1, and all subsequent matches anchored to the previous match?

Similar considerations may hold for the :nth and :x modifiers.



Perl 6 member

The only effect of :pos is to set the starting position. :pos(0) is a no-op, in other words.

Perl 6 member

So, just to confirm: when :global, :overlap, :nth, or :x are set, then :pos($n) acts exactly like :c($n) would?


Perl 6 member

Sorry, was confusing :p with :c due to either illness or stupidity (or both). :p will anchor, so only :ex has any effect (return all anchored variations). All other modifiers should fail with :p, pointing toward use of :c instead.

@TimToady TimToady added a commit that closed this issue Jul 28, 2012
@TimToady TimToady :p is incompatible with scanners
:p may not be used with :ex, :ov, :g, :nth, or :x modifiers.
fixes #16
@TimToady TimToady closed this in 76c977a Jul 28, 2012
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.