Skip to main content
Known Participant
September 18, 2019
Question

Wanteed a Grep in Indesign to search for white spaces

  • September 18, 2019
  • 1 reply
  • 2408 views

Hi team,

I wanted a grep in Indesign which can search the white spaces before a letter (alphabet or digit) and has a specific Paragragh style and then replace the white Nonbreaking Space (Fixed Width).

The spaces before the letter can be one or many. This is used for the indentaion of the codes.

For Example:

Please help me.

 

Regards

Arvind

 

    This topic has been closed for replies.

    1 reply

    vladan saveljic
    Inspiring
    September 18, 2019

    if the spaces you want to replace are always after soft return (as in your screenshots) one way to find them could be this grep

    \n\K\x20+

    Known Participant
    September 25, 2019

    Thanks for the reply.

    But unfortuntately sometime I have hard enters also. I am look for a grep which could find the space before a letter or a digit of a paragraph style.

    I have searched with the Grep that you have provided me:

    Find: \K\x20+
    Replace:  ~s

    but when I replace with Non-Breaking space all the spaces are replaced with one. I want all the spaces to be replaced with Non-breaking spaces.

     

    Please help me.

     

    Regards

    Arvind

    vladan saveljic
    Inspiring
    September 25, 2019

    the Number of spaces are not always the same, it depends upon the Indentation of Codes.
    It starts from 1 space and goes upto 20-30 spaces.


    You could make this in 2 steps:

    step 1)

    find ANY space and replace with non breaking spaces

    Find

    \x20

     

    Replace with

    ~s

     

    step 2)

    Find

    ([[:graph:]])(~s)([[:graph:]])

     

    Replace with

    $1"digit one space with spacebar"$3