Page 1 of 1

Search in "Find in files" result

Posted: Tue Mar 23, 2021 4:45 pm
by JDL_CYT
Hello,

I'm not comfortable with xml, other than just writing in author mode so please keep it simple ;)

I need to exchange the word "dialog" to "dialog box" in multiple places in my bookmap. However, I also have entries that are already correct, i.e. "dialog box". If I do a find and replace all, the outcome in some cases will be "dialog box box". So far, I have gone from there and replaced "box box" with just "box".

When doing a search and replace in files, a tab with the findings appear (all my "dialog" hits), and in this list, files can be removed (those already correct "dialog box"). I was hoping I could start from this list (the one with "dialog box" removed), and replace only the entries that are left. Is there a way to do that?

Thanks in advance!

Re: Search in "Find in files" result

Posted: Tue Mar 23, 2021 6:31 pm
by adrian
Hello,

The preview of the Replace in Files allows you to uncheck some of the files from the list. So, if the file granularity is fine, than sure, it can be done that way. But note that if you have files where both "dialog" and "dialog box" appear, you can't fix it.

It is actually possible to search for both "dialog" and "dialog box" whichever occurs (largest match) with the help of a regular expression.
Find: dialog( box)*
Replace with: dialog box
[x] Regular expression
( box)* means the space and box are optional.
This ensures that "dialog box" and "dialog" are replaced with "dialog box".

It's also possible to search for "dialog not followed by box". It can be done like this:
Find: dialog(?! box)
Replace with: dialog box
[x] Regular expression
Where (?! box) means not followed by space and box.
So, this replaces "dialog not followed by box" with "dialog box".

Regards,
Adrian

Re: Search in "Find in files" result

Posted: Wed Mar 24, 2021 4:00 am
by chrispitude
Hi JDL_CYT,

Here is a webpage where you can play around with regular expressions. I put Adrian's second example in the fields for you.

https://regex101.com/r/YAHVVF/1

- Chris

Re: Search in "Find in files" result

Posted: Wed Mar 24, 2021 2:35 pm
by JDL_CYT
Thank! I will try those!
:D