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

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

Advocate ,
Feb 06, 2025 Feb 06, 2025

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!

 

 

TOPICS
How to
215
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

correct answers 1 Correct answer

Advocate , Feb 06, 2025 Feb 06, 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?

 

Translate
Community Expert ,
Feb 06, 2025 Feb 06, 2025
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 ,
Feb 06, 2025 Feb 06, 2025

Or rather this - Positive Lookahead:

 

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

 

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
Guide ,
Feb 06, 2025 Feb 06, 2025

Grep Find: :(?=\S)

Grep Replace by: $0 

($0 followed by a normal space)

 

(^/)  The Jedi

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
Advocate ,
Feb 06, 2025 Feb 06, 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?

 

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
Guide ,
Feb 06, 2025 Feb 06, 2025

Yes! You simply search ":"

 

(^/)

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
Advocate ,
Feb 06, 2025 Feb 06, 2025

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

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
Guide ,
Feb 06, 2025 Feb 06, 2025
LATEST

The regex will find ALL the ":" followed by a char that is a "\S"

 

That means no catch if the ":" is followed by a normal space, a no-break space, a tab, a carriage-return, a soft-return, …

 

(^/)

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