Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

formatting change while applying changeAll

Community Beginner ,
Jun 13, 2025 Jun 13, 2025

Hi everyone,

 

I'm facing an issue with InDesign find and replace and hoping someone here can help.

Trying to insert a discretionary hyphen before a specific pattern in the text. I use a positive lookahead regex pattern (?=\w+~_) to find the target position and insert '~-', but this only works for the first occurrence in a text frame. To work around this, I tried switching the approach to use a matching regex: (\w+~_) and then use the replace string as ~-$0~k. However, when I give changeAll with this, I'm losing the character formatting (e.g., bold text gets reverted to Roman). Interestingly, when I use change one at a time, the formatting is preserved.

Has anyone encountered this issue or found a workaround to keep the formatting intact while using changeAll? Or Am I missing something in the positive lookahead pattern.

Thanks in advance for any suggestions!

 

Screenshot 2025-06-13 at 9.47.56 pm.png

TOPICS
Bug
178
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 13, 2025 Jun 13, 2025

The problem seems to be that you replace chunks of text while all you want to do ir insert some text.

 

In your case, you can insert the discr hyphen at the insertion point before the em rule:

Find: (?=~_)
Change: ~k

The Find string is just the lookahead, in other words, the insertion point before what's matched by the lookahead.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 16, 2025 Jun 16, 2025

Hi @Peter Kahrel,

 

Thanks for your response. But I need to insert the discrestionary hyphen in the begining of the word and after the Em-dash.

 

Thanks,

Sathish

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2025 Jun 16, 2025
LATEST

In that case you use a lookbehind: (?<=~_)

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines