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

How to replace all using grep?

Explorer ,
May 26, 2022 May 26, 2022

Copy link to clipboard

Copied

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

Views

138

Likes

Translate

Translate

Report

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

Likes

Translate

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

Copy link to clipboard

Copied

Can you share a sample document that exibhits this behaviour.

-Manan

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Here's a sample.

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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 )

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Good idea!

Likes

Translate

Translate

Report

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