On Mar 7, 2020, at 5:12 AM, Roland Küffner <medienmeis...@gmail.com> wrote:
> 
> It is a little confusing or unintuitive(*), that the pattern FINDS both 
> instances but only CAPTURES the last one. But once you understand the 
> mechanism it is a lot easier to construct working patterns.

I think it may make more sense if you think that you get one capture group for 
result for each parenthesized subexpression in the regular expression. That is, 
the set of capture groups maps onto the text of the regular expression as it is 
written.

Since, because of repetition, a parenthesized expression may match multiple 
substrings when the pattern is actually applied, that leaves the question of 
which of the matches for a subexpression is actually captured. The choice is 
somewhat arbitrary, but from a purely practical point of view, if the first 
match was captured, there would, in general, be no way to get the last match; 
but if the last match is captured, you can always get the first ,match as well 
with a little recoding of the regular expression.

Regards,

        Neil Faiman

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" 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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/3621FB10-3D84-40C0-868F-1996A9514C25%40faiman.org.

Reply via email to