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
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.
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 :
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
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.
Copy link to clipboard
Copied
Right, add "^" at the beginning - start of paragraph - and "$" at the end:
^\d\d\d$
00$0
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
Copy link to clipboard
Copied
Yeah, word boundary will work as well.
And to be even more "direct" - you can specify ParaStyle.
Copy link to clipboard
Copied
thanks robert and jm 🙂
both solutions work well.