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

How to replace all using grep?

Participant ,
May 26, 2022 May 26, 2022

Hi.

 

I have a space before and after every footnote number in the text and I want to remove them, I used

Find: (~F) 

Change to: $1

 

When I do it one by one it works perfectly, but when I use change all it doesn't work it turns them into squares.

What am I doing wrong here?

TOPICS
How to
1.1K
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 , May 28, 2022 May 28, 2022

Hi @AK09M, try this:

((?<=~F) | (?=~F))

This searches for a space with a footnote number before it OR a space with a footnote number after it.

- Mark

Translate
Community Expert ,
May 26, 2022 May 26, 2022

Can you share a sample document that exibhits this behaviour.

-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
Participant ,
May 26, 2022 May 26, 2022

Here's a sample.

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 ,
May 28, 2022 May 28, 2022

Hi @AK09M, try this:

((?<=~F) | (?=~F))

This searches for a space with a footnote number before it OR a space with a footnote number after it.

- 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
Community Expert ,
May 28, 2022 May 28, 2022

Hi @AK09M and @m1b,

The problem is not searching but replace and it seems we can't replace a footnote marker with itself using change all, it replaces it with something like <?>. It happens on every document. So I suggest to do this in two steps.

 

Find What
\x20(?=~F)

Change To:- Leave it empty

 

Second step

 

Find What
(?<=~F)\x20

Change To: Again leave it empty

 

-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 Expert ,
May 29, 2022 May 29, 2022

Hi @Manan Joshi, I think my suggestion works okay—it just targets the spaces, which you can just replace with nothing, so it avoids attempting to replace footnote numbers.

- 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
Community Expert ,
May 29, 2022 May 29, 2022

Thanks for adding this @m1b. I was so engrossed in finding why the replace all is not working that I forgot carefully to look at the grep you mentioned. I just complicated your statement by breaking into two steps. The key here was not replacing the footnote or to say replace by nothing, since you did not emphasize on it, I thought that maybe there is something more to be looked into.

-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 Expert ,
May 31, 2022 May 31, 2022

Hi Mark and Manan,

to make it more clear that there is a space in the GREP expression:

use the Unicode notation.

 

((?<=~F)\x{0020}|x{0020}(?=~F))

 

Best,

Uwe Laubender
( Adobe Community Professional )

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 ,
May 31, 2022 May 31, 2022

Hi @Laubender,

Thanks for the suggestion. I had used it. I dissected @m1b's expression into two and you combined mine and his into one 🙂

-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 Expert ,
May 31, 2022 May 31, 2022
LATEST

Good idea!

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