Skip to main content
Participant
December 7, 2024
Answered

InDesign 18.3 crashing when I run GREP commands

  • December 7, 2024
  • 3 replies
  • 242 views

Hello,
I am running InDesign 18.3 (because I had issues with newer versions and just decided to stya put) on Windows 10. When I run general find and replace commands, I have no issues. When I run most GREPs, I have no issues. When I run this GREP \h+(?!\n)$ to remove trailing spaces, the program crashes. I have run this in the past without issue. Only the last two times I have used InDesign have given me trouble. Any help would be appreciated.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Eugene Tyson

Why the (?!\n) seems superflous.

How about \h+$ instead

 

3 replies

Eugene TysonCommunity ExpertCorrect answer
Community Expert
December 7, 2024

Why the (?!\n) seems superflous.

How about \h+$ instead

 

Participant
December 7, 2024

To be honest, I am not sure why I had it that way. Someone else had given methat specific expression and I never thought twice. I tried \h+$ and it worked fine. Still not sure why the other was causing InDesign to crash though.

Community Expert
December 8, 2024

Seems contradictory - not sure either didn't try it myself. 

 

Essentially, this regex is trying to match spaces at the end of a line or paragraph, but only if there's no line break following them.

The $ anchor already means "end of a line or string," and by definition, there won’t be a character after it. Adding a lookahead to ensure that a line break (\n) isn't present seems redundant in many contexts because $ generally implies there's no visible character following.

However, it could have been written for a very specific context, like when working with certain multiline processing options where $ doesn't necessarily imply the end of the string but rather the end of a line before a line break. In those cases, (?!\n) would prevent matches where a line break immediately follows the spaces.