Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do you understand that ((^\s)*)(abc) has 3 groups and abc is $3?

Guide ,
Jun 02, 2025 Jun 02, 2025
((^\s)*)(abc)

I originally thought that with one set of brackets, abc should be $2.
But in fact, abc is $3

 

But the expression:

([,,\h]*)(abc) 

Here abc is $2.

TOPICS
Bug , Feature request , Scripting
303
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jun 02, 2025 Jun 02, 2025

You have 3 capture groups. (ABC) is the third.

 

if you're not sure, just count the "(" from the left ... 1, 2, 3!

 

P.S. in your second example you have 2 capture groups and (abc) is the second. 

Translate
Community Expert , Jun 02, 2025 Jun 02, 2025

Well, yes, once for each found instance.

 

Try this experiment, using text frame with "abcdefghijklmnopqrstuvwxyz".

1. findWhat: 

(abc)(def(ghi)jkl)(mno)

2. changeTo:

0 = $0\r1 = $1\r2 = $2\r3= $3\r4 = $4\r\rnot captured = 

 

So start with this: demo-0.png

 

Then perform the find/change on the text. You will see this:

demo-1.png

 

We have split up the capture groups and shown them with the index. Maybe it will help you to look carefully at what is going on here, especially the nested group that captures "ghi".

- Ma

...
Translate
Community Expert ,
Jun 02, 2025 Jun 02, 2025

You have 3 capture groups. (ABC) is the third.

 

if you're not sure, just count the "(" from the left ... 1, 2, 3!

 

P.S. in your second example you have 2 capture groups and (abc) is the second. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 02, 2025 Jun 02, 2025

One bracket captured once?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 02, 2025 Jun 02, 2025

Well, yes, once for each found instance.

 

Try this experiment, using text frame with "abcdefghijklmnopqrstuvwxyz".

1. findWhat: 

(abc)(def(ghi)jkl)(mno)

2. changeTo:

0 = $0\r1 = $1\r2 = $2\r3= $3\r4 = $4\r\rnot captured = 

 

So start with this: demo-0.png

 

Then perform the find/change on the text. You will see this:

demo-1.png

 

We have split up the capture groups and shown them with the index. Maybe it will help you to look carefully at what is going on here, especially the nested group that captures "ghi".

- Mark

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 02, 2025 Jun 02, 2025
LATEST

There's still this kind of play.
Worship.

020.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 02, 2025 Jun 02, 2025

Count the brackets ()      😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines