Skip to content
This repository

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

Closed
pmichaud opened this Issue July 07, 2012 · 3 comments

2 participants

Patrick R. Michaud Larry Wall
Patrick R. Michaud
Owner

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.

Thanks!

Pm

Larry Wall
Owner

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

Patrick R. Michaud
Owner

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

Pm

Larry Wall
Owner

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.

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