Re: Capture group question

2020-03-07 Thread Neil Faiman
On Mar 7, 2020, at 5:12 AM, Roland Küffner 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

Re: Capture group question

2020-03-07 Thread Roland Küffner
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

Re: Capture group question

2020-03-06 Thread Fletcher Sandbeck
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.

Capture group question

2020-03-06 Thread Howard
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

Re: Capture group question

2020-03-01 Thread Tom Robinson
It lets you use parenthesis without creating a capture group. If you’re looking for ‘def’ in this line: abc def Then you could use: (abc) (def) But your ‘def’ would end up in capture group 2. If you instead use: (?:abc) (def) Then ‘def’ will be in capture group 1.

Re: Capture group question

2020-03-01 Thread 'anotherhoward' via BBEdit Talk
fletcher, Your change addressed my question. If you could explain what `?:` does I would much appreciate it. Howard On Sunday, March 1, 2020 at 11:00:58 AM UTC-5, flet...@cumuli.com wrote: > > I think the problem is that the {2} calling for a repetition of the > previous pattern is outside

Re: Capture group question

2020-03-01 Thread Fletcher Sandbeck
I think the problem is that the {2} calling for a repetition of the previous pattern is outside the parentheses which signal the capture. You can use a non-capturing group (?: ) to group patterns without creating another capture. And then wrap the entire new expression with the repetition in

Capture group question

2020-03-01 Thread 'anotherhoward' via BBEdit Talk
In the Pattern Playground, I am running this pattern -> *(\d{3}[-.]){2}(\d{4})* with the data shown below. Here is my input data: 123.179-9876 123.456-9876 123-456-9870 126-456-987 1257-456--0 123-456 12345 Three capture groups are shown in the *Capture groups* box. [image: Screen Shot