On 3/17/22 at 7:58 AM, [email protected] (Neil Faiman) wrote:

On Mar 16, 2022, at 5:24 PM, Patrick Woolsey <[email protected]> wrote:

In *Find: ^(\d+?)\.1 *what is the purpose of the question mark? [...]

It makes matching "non-greedy", so the pattern won't try to extend beyond the 
first possible match.

In this particular case, the ? doesn’t have actually have any effect — the longest string of digits that is immediately followed by a dot is exactly the same as the shortest String of digits that is immediately followed by a dot, since a dot is not a digit. But the non-greedy modifier can be essential when a repeated wild-card pattern would otherwise match right over what is supposed to be the terminator.

That's correct, provided the shape of the actual data exactly parallels that of the example but I've learned to take precautions whenever possible. ;-)


Regards,

  Patrick Woolsey
==
Bare Bones Software, Inc.             <https://www.barebones.com/>


--
This is the BBEdit Talk public discussion group. If you have a feature request or need 
technical support, please email "[email protected]" rather than posting here. 
Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/r480Ps-10146i-DD4D2C6EA98E4BEEB141DB693D65BAE0%40Cylinder.local.

Reply via email to