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

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

Advocate ,
Feb 06, 2025 Feb 06, 2025

Copy link to clipboard

Copied

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

Views

164
Translate

Report

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?

 

Votes

Translate
Community Expert ,
Feb 06, 2025 Feb 06, 2025

Copy link to clipboard

Copied

Votes

Translate

Report

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

Copy link to clipboard

Copied

Or rather this - Positive Lookahead:

 

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

 

Votes

Translate

Report

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

Copy link to clipboard

Copied

Grep Find: :(?=\S)

Grep Replace by: $0 

($0 followed by a normal space)

 

(^/)  The Jedi

Votes

Translate

Report

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

Copy link to clipboard

Copied

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?

 

Votes

Translate

Report

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

Copy link to clipboard

Copied

Yes! You simply search ":"

 

(^/)

Votes

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Report

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

Copy link to clipboard

Copied

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, …

 

(^/)

Votes

Translate

Report

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