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

GREP code help - change parentheses into brackets

Community Beginner ,
Apr 24, 2019 Apr 24, 2019

Hi,

I work with InDesign for a while, but I am not very familiar with the coding features. I am struggling with wich seems a simple issue.

What I would like to do is:

change (9) into [9]

In the text body - change any numbers that are in parentheses into numbers in brackets.

In GREP, I can find all such occurences in text with simple code \(\d\), but I do not know what to put into the Change to: field.

I know it might be silly easy, but I just don't know and will be grateful for any help.

Thanks in advance.

Martin L.

TOPICS
Scripting
1.5K
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 1 Correct answer

Community Expert , Apr 25, 2019 Apr 25, 2019

Hi Martin,

Try the following

FindWhat :-  \((\d+)\)

Change To :- [$1]

-Manan

Translate
Community Expert ,
Apr 25, 2019 Apr 25, 2019

Hi Martin,

Try the following

FindWhat :-  \((\d+)\)

Change To :- [$1]

-Manan

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 Beginner ,
Apr 25, 2019 Apr 25, 2019

Hi Manan,

that works just fine, thank you very much.

What is the difference in that FindWhat query you used, because when I was using that mine \(\d\) and used [$1] in ChangeTo, it only put [$1] into text body as a replacement.

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 ,
Apr 25, 2019 Apr 25, 2019

Hi Martin,

In your FindWhat query you were not creating a capturing group so there was no group associated with $1, hence it was replaced literally. In my query i create a capturing group by enclosing the number part within () this would set $1, which would correspond with the number part of the search result.

Hope this made sense

-Manan

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 Beginner ,
Apr 25, 2019 Apr 25, 2019
LATEST

ok, it makes sense, yes.

Thank you again, have a good day.

m.

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