Skip to main content
Bedazzled532
Inspiring
September 1, 2022
Answered

Weird behaviour of Find Change GREP

  • September 1, 2022
  • 1 reply
  • 495 views

I have an object which I want to place after Footnote reference denoted by a character style named "Reference"

 

I copied the object by CTRL+C and doing a Find Change usign GREP.

 

Here are the Parameters of Find and Change:

F: ~F
R: $0~c
Find Format: Character Style: reference

 

The weird thing is that if I do Find and then Change it works but when I do Find and Change All, its pastes the object but instead of Footnote reference its shows <?>

 

Meaning Single Find/Change works but Find/Change All not working.

 

Attaching a screenshot.

How to resovle this issue ? Plz help.

Thanks and regards

This topic has been closed for replies.
Correct answer Manan Joshi

Try the following

Find What:- (?<=~F)
Replace With:- ~c
Find Format: Character Style: reference

-Manan

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
September 1, 2022

Try the following

Find What:- (?<=~F)
Replace With:- ~c
Find Format: Character Style: reference

-Manan

-Manan
Bedazzled532
Inspiring
September 1, 2022

Thank you so much Manan. It worked like a charm.

 

Just for the sake of learning, could you explain why lookbehind has been used ? As per the rules of lookbehind, it should find something if (?<=~F) is behind. Ideally there should be something after this (?<=~F).  I always get confused in this stuff. Thanks a lot once again for solving my issue.

Community Expert
September 2, 2022

There are two things

  • Why your approach of finding footnote reference and then replacing it did not work. Well this is a known thing and replacing footnote reference with itself does not work. So we needed to find an alternative
  • I used positive lookbehind to find the postion after the footnote reference. Now positive lookbehind mean to find a location which is preceded by the character, and since it does not capture what it matches it means that we have our cursor at the blank location after or searched term. So using lookbehinds/aheads in conjuction with other terms is a use case but not the only use case.

I hope this explains you my approach to the problem

See the following

https://regex101.com/r/8k0RC8/1

Notice the cursor right after e and the search result is null. So this is what a lookbehind/ahead means in itself.

-Manan

-Manan