Skip to main content
Inspiring
August 22, 2024
Answered

How to Use GREP for Searching First/Last Character on a Line in InDesign?

  • August 22, 2024
  • 2 replies
  • 566 views

Hi

 

Is there any way with GREP to  search the first and last characters of a line (not paragraph) as it flows in InDesign? Please see example attached.

 

I'm trying to locate all lines that begin with a hyphen, or terminate with "I" etc so I can reflow them for stylistic purposes, but I'm not sure if GREP can interact with the text flow in this way, and there don't seem to be any hidden characters at automatic line breaks that GREP could locate.

 

Again this is not about the first character in a paragraph, so '^' isn't any use here I don't think.

I'm currently polishing a 400 page book whose author is a bit hyphen/en-dash crazy so having a way to automate this search woud be a lot faster and less error prone.

 

Is this possible?

Many thanks
Richard

 

 

<TIle renamed by MOD>

This topic has been closed for replies.
Correct answer Barb Binder

Hi @craftycurate:

 

GREP can target seven locations: beginning of word, end of word, word boundary, beginning of paragraph, end of paragraph, beginning of story and end of story. Unfortunately, beginning and end of a line within a paragraph is not an option. 

 

~Barb

2 replies

Robert at ID-Tasker
Legend
August 22, 2024

@craftycurate 

 

You can either replace space after those shorts with a non breaking space - or use GREP style to apply CharStyle with a NoBreak.

 

https://graphicdesign.stackexchange.com/a/114123

 

This is a GREP style to use:

 

 

(?<=[!\?\.]\s)[^\s]{1,3}\s

 

 

https://community.adobe.com/t5/indesign-discussions/avoid-a-single-letter-at-the-end-of-a-line/td-p/12566008

 

Barb Binder
Community Expert
Barb BinderCommunity ExpertCorrect answer
Community Expert
August 22, 2024

Hi @craftycurate:

 

GREP can target seven locations: beginning of word, end of word, word boundary, beginning of paragraph, end of paragraph, beginning of story and end of story. Unfortunately, beginning and end of a line within a paragraph is not an option. 

 

~Barb

~Barb at Rocky Mountain Training