Fletcher, thanks for the very helpfull link. To summarize that discussion:
the {2} tells the capture group to look twice for it‘s pattern, but the
capture group only saves the last instance it found. Putting the whole
search term into another capture group should give you the desired result
(as the #0 suggests).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. Regards, Roland (*) hm, giving that a second thought I cannot come up with a place where the abstract beauty of regular expressions is blurred by stains of things like intuition :-) Fletcher Sandbeck <[email protected]> schrieb am Sa. 7. März 2020 um 05:58: > There's a good discussion at the following URL but it occurs because the > regular expression is evaluated as a state machine. Here the capturing > group itself is repeated by the {2}. The first match is discarded when it > sees the second match and that's what you see in the results. > > https://www.regular-expressions.info/captureall.html > > [fletcher] > > > On Mar 6, 2020, at 7:25 PM, Howard <[email protected]> wrote: > > When using the Pattern Playground, in the search pattern's capture group > #1 (see below), why is `847-` appearing rather than `717-`? > > Search pattern: (\d{3}[.-]?){2} > > Source text: 717-847-8015 > > Capture Groups: > #0: 717-847- > #1: 847- > > -- > 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/32702e50-f03b-4a76-94a1-6974886c4f0b%40googlegroups.com > <https://groups.google.com/d/msgid/bbedit/32702e50-f03b-4a76-94a1-6974886c4f0b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > -- > 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/DC6CF50B-B3E8-452D-BC30-2B0033B0C79B%40cumuli.com > <https://groups.google.com/d/msgid/bbedit/DC6CF50B-B3E8-452D-BC30-2B0033B0C79B%40cumuli.com?utm_medium=email&utm_source=footer> > . > -- 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/CABybPXYTqQn7ej2HB-8Nm2S_8KV2ZPH_4u8Gi6AZAeGi1m8-ag%40mail.gmail.com.
