Skip to main content
Inspiring
May 26, 2022
Answered

How to replace all using grep?

  • May 26, 2022
  • 3 replies
  • 951 views

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?

This topic has been closed for replies.
Correct answer m1b

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

3 replies

Community Expert
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 )

Community Expert
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

-Manan
m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
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

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

-Manan
m1b
Community Expert
Community Expert
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

Community Expert
May 26, 2022

Can you share a sample document that exibhits this behaviour.

-Manan

-Manan
AK09MAuthor
Inspiring
May 26, 2022

Here's a sample.