Skip to main content
Inspiring
February 6, 2025
Answered

GREP: don't select/exclude character after find result?

  • February 6, 2025
  • 3 replies
  • 678 views

I have a doc full of text without spaces after colons, e.g. "Next Step:Organize Tools."

I want to add a space after the colon.

Terms like "Next Step" appear regularly throughout, and are easy to find; additionally, there are URLs in which I don't want to add space after a colon.

- - -

So, I can search for "Step:\S" which finds the colons, but it also selects the next letter, e.g. "Next Step:Organize Tools."

- - -

How do we tell GREP to NOT select the next character, and simply add a space after the colon?
FWIW I have the GREP in InDesign book, but don't know what this function is called & couldn't find it... 

Thanks!

 

 

Correct answer turner111

Thanks @Rob @FRIdNGE 
I looked a bit closer at the book and indeed kind of found this solution, for example:

Find Step:(?=\S)

Replace Step:_    (that's just a space, not an underscore.)

 

@FRIdNGE , this seems to work, but is there an advantage to using $0?  I think you're maybe just referring to the find result?

 

3 replies

turner111AuthorCorrect answer
Inspiring
February 6, 2025

Thanks @Rob @FRIdNGE 
I looked a bit closer at the book and indeed kind of found this solution, for example:

Find Step:(?=\S)

Replace Step:_    (that's just a space, not an underscore.)

 

@FRIdNGE , this seems to work, but is there an advantage to using $0?  I think you're maybe just referring to the find result?

 

FRIdNGE
February 6, 2025

Yes! You simply search ":"

 

(^/)

turner111Author
Inspiring
February 6, 2025

Wouldn't that find every instance of ":" though?

FRIdNGE
February 6, 2025

Grep Find: :(?=\S)

Grep Replace by: $0 

($0 followed by a normal space)

 

(^/)  The Jedi

Robert at ID-Tasker
Legend
February 6, 2025

Or rather this - Positive Lookahead:

 

https://carijansen.com/positive-lookahead-grep-for-designers/