On Fri, Aug 12, 2011 at 09:11:08PM -0700, Warren Michelsen wrote:
> I must be misunderstanding how {1}? works.
Normally, quantifiers (? * + {n,m}) match as many times as possible.
Adding a ? after a quantifier makes it match as few times as possible.
(To be more precise, normally the longest leftmost match is found; adding ?
after a quantifier means the shortest leftmost match is found.)
So, {n}? means match exactly n times, but as few as possible. But the only
possibility is exactly n times, so adding the ? doesn't have any effect.
Further, {1} means match exactly 1 time. But without a quantifier it
matches 1 time anyway, so {1} also has no effect.
> I would expect (^time : (?s).*) to match the entire document and it does.
>
> So where do I place the {1}? to limit the find to the second, not third
> instance of ^time : ?
>
> Using "(^(time : ){1}?(?s).*)^time" selects up to the third ^time.
I believe this is what you're looking for:
(^time : (?s).*?)^time
You want to match any character, as few times as possible to get to ^time.
You were on the right track; you were just adding the question mark in the
wrong place.
Ronald
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>