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

Wanteed a Grep in Indesign to search for white spaces

Explorer ,
Sep 18, 2019 Sep 18, 2019

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:

clipboard_image_0.png

clipboard_image_1.png

Please help me.

 

Regards

Arvind

 

2.2K
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 ,
Sep 18, 2019 Sep 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+

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
Explorer ,
Sep 24, 2019 Sep 24, 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

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 ,
Sep 24, 2019 Sep 24, 2019

are the spaces you want to find and replace, always at the beginning of paragraph?

in that case try this grep:

^\x20+

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
Explorer ,
Sep 25, 2019 Sep 25, 2019

awesome. This is working.
But can you please guide me what will be the replace Grep.

 

clipboard_image_0.png

Or something else.

OR

clipboard_image_0.png



Thanks for your reply.

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 ,
Sep 25, 2019 Sep 25, 2019

^ = beginning of paragraf

\x20 = space

+ = one or more times

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
Explorer ,
Sep 25, 2019 Sep 25, 2019

Hi Vladan,
Thanks for the reply but I am not able to replace with the Non-Breaking spaces.
I have tried many options but I am not able to do it.
Please help me.
I want the replace to be like this:
Before:

 

clipboard_image_1.png


After:

clipboard_image_2.png

I have done this manually

 

 

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 ,
Sep 25, 2019 Sep 25, 2019

ok. is the number of spaces always the same?

if not, how many variables are there?

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
Explorer ,
Sep 25, 2019 Sep 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.

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 ,
Sep 25, 2019 Sep 25, 2019

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

 

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
Explorer ,
Sep 25, 2019 Sep 25, 2019

I am sorry. The given suggestion is not working.

The Grep given by you is working perfectly to my requirement:
^\x20+

But I am not able to replace the white spaces with Non Breaking space

 

 

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 ,
Sep 25, 2019 Sep 25, 2019

try my modified suggestion before your last post

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
Explorer ,
Sep 25, 2019 Sep 25, 2019

Marvelous. You are rockstar.
Its working for me.
To help me understand.
Its finding all the whitespace in the document and replacing it with a Non Breaking space.
and then its finding the Non Breaking space between the letter and its replacing it with white space.

 

 

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 ,
Sep 25, 2019 Sep 25, 2019

in the step 2 the grep finds non breaking space between any graphical character: letter, digit, punctuation character, etc... (not only letter)

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
Explorer ,
Sep 25, 2019 Sep 25, 2019

Thanks for help and support.
If possible can you help me with one more thing.
I want to enhance my skills in making Greps in Indesign.
Can you provide be any reference or any tutorials.

Regards
Arvind

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 ,
Sep 25, 2019 Sep 25, 2019

maybe you could do this in ONLY ONE step.

Try it

 

Find

(?<![[:graph:]])\x20

 

Replace with

~s

 

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 ,
Sep 25, 2019 Sep 25, 2019
LATEST
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