Copy link to clipboard
Copied
Hi,
While using the grep in coding, the character style is applied additionally within the word, please suggest an alternative method if any.
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = "(?<=-)([[:word:]]+)";
app.changeGrepPreferences.changeTo = "~-~k$0";
app.documents.item(0).changeGrep();
Original (see color text):
After executing the code (see color text):
Thanks,
Selva
I missed something in your original post. So the character style is applied but you don't want that, correct? The character style is probably already there. What is that red 3 doing there? Is that a footnote or endnote with a style applied? Well, I still can't reproduce it. What else is there? Can you show a screenshot of the story editor?
Here's another formulation to try:
Find what: -(?=\w)
Change to: -~-~~k
Copy link to clipboard
Copied
Works ok here. Which InDesign version do you use? Maybe try a different formulation, e.g.
\K(\w+)
which means the same as your expression.
Copy link to clipboard
Copied
Hi Kahrel,
Thank you so much for the quick response. I have used CC2019 (14.0.3) and the CC2017 (12.1.0.56). I will try the suggested method and get back to you shortly.
Thanks,
Selva
Copy link to clipboard
Copied
Hi Kahrel,
Related with this testing, when I'm using the manual grep replace method with one by one, it's working fine (see below 1st screenshot). But I have used the 'Change All' option manually, it's going wrong (see 2nd screenshot). The same concept is working in coding itself. So, can I consider this for InDesign default behavior and no need to change the coding? Please guide me if I'm wrong.
Change All:
Thanks,
Selva
Copy link to clipboard
Copied
I missed something in your original post. So the character style is applied but you don't want that, correct? The character style is probably already there. What is that red 3 doing there? Is that a footnote or endnote with a style applied? Well, I still can't reproduce it. What else is there? Can you show a screenshot of the story editor?
Here's another formulation to try:
Find what: -(?=\w)
Change to: -~-~~k
Copy link to clipboard
Copied
Hi Kaherl,
Thanks for focus on this topic. The character style is applied to one character in originally, but I don't want to modify anything here, just I try to insert the break character before the word. Below my reply with 'Ans:'.
Your suggestion is working fine with small changes, reference here:
---
app.findGrepPreferences.findWhat = "-(?=\\w)";
app.changeGrepPreferences.changeTo = "$0~-~k";
app.documents.item(0).changeGrep();
---
Kindly let me know if not clear.
Thanks,
Selva
Copy link to clipboard
Copied
Hi Kaherl,
Kindly suggest to alternate this code too,
app.findGrepPreferences.findWhat = "[[:word:]]+(?=-)";
app.changeGrepPreferences.changeTo = "~-$0";
app.documents.item(0).changeGrep();
Thanks,
Selva
Copy link to clipboard
Copied
app.findGrepPreferences.findWhat = " (?=\\w+-)";
app.changeGrepPreferences.changeTo = "$0~-";
app.documents.item(0).changeGrep();
Find more inspiration, events, and resources on the new Adobe Community
Explore Now