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

indesign grep : 3 and 4 digit numbers to 5 digits by adding zeros

Community Beginner ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

hello,

 

in an indesign catalog i would like to change 3 and 4 digit numbers to 5 digits.

3 digit numbers should get 2 zeros up front, 4 digit numbers should get one zero.

5 digit numbers should remain unchanged.

f.i. :

465 -> 00465

5567 -> 05567

23167 -> 23167

 

i'm pretty sure this can be done by a grep find and replace, but i don't know how.

any help is appreciated.

 

rené bosch

TOPICS
How to

Views

217

Translate

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

Yes, but knowing current "surrounding" of the digits would be helpful - can you share a screenshot?

 

Would have to be done in two steps anyway. 

 

Votes

Translate

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 Beginner ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

hi robert,

 

the numbers are in a table and have paragraph styles. here is a screenshot, it concerns the bold numbers only :

Scherm­afbeelding 2024-04-29 om 12.37.32.png

Votes

Translate

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

I'm on my phone so I'll just brainstorm... 

 

[1-9]\d\d\d

 

00$0

 

and

 

[1-9]\d\d\d\d

 

0$0

 

Votes

Translate

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 Beginner ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

thanks robert.

unfortunately, '[1-9]\d\d\d' finds the first 3 digits in a 4 digit number as well. that should not be the case.

Votes

Translate

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

Right, add "^" at the beginning - start of paragraph - and "$" at the end:

 

^\d\d\d$

 

00$0

 

Votes

Translate

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

Try this, and as @Robert at ID-Tasker wrote, you'll need 2 steps:

For the 3 digits numbers

Find: \b\d{3}\b

Replace: 00$0

 

For the 4 digits numbers

Find: \b\d{4}\b

Replace: 0$0

Votes

Translate

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

Yeah, word boundary will work as well.

 

@renéb52836404

 

And to be even more "direct" - you can specify ParaStyle.

 

Votes

Translate

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 Beginner ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

LATEST

thanks robert and jm 🙂

both solutions work well.

 

Votes

Translate

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