Copy link to clipboard
Copied
Hi there,
Please can someone help.
Is there a way to limit findGrep to finding whole words?
For example, if I'm searching for employee the word employees wouldn't be a match because of the 's'.
Thanks in advance.
Another way, depending on your situation, is to include word boundary symbols \b in your grep. So
\bant\b
will find the word "ant", and won't find the "ant" in "rant" or "anthropic".
- Mark
Copy link to clipboard
Copied
Hi @deckarduk , I think you would have to do a find text to get at the whole word option. See the FindChangeTextOption.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindChangeTextOption.html
Copy link to clipboard
Copied
Hi Rob,
Thanks for the help.
I've had a look at the link, the whileWord attribute looks like what I need.
I'm presuming with the FindChange option I'd have to find the word and then change it?
Copy link to clipboard
Copied
Another way, depending on your situation, is to include word boundary symbols \b in your grep. So
\bant\b
will find the word "ant", and won't find the "ant" in "rant" or "anthropic".
- Mark
Copy link to clipboard
Copied
Hi Mark,
Thanks for the help and grep snippet. It worked a treat!
In my code I had to add escape characters to the \b so ended up with \\bemployee\\b, which worked.
Thanks again 🙂