Skip to main content
Participating Frequently
December 18, 2022
Answered

indesign grep code for adding point s in thousands and tenthousands

  • December 18, 2022
  • 2 replies
  • 585 views

hi everybody,

 

i'm not very familiar with grep (hope to be one day), but i think what i'm looking for shouldn't be that hard to write.

in an indesign document with thousands of prices, a point should be added if the prices are thousands or ten thousands. so f.i. 23567, 89 should be 23.567,89 and 1273,25 shoud be 1.273,25, but 899,56 should not be .899,56.

i did create for 'Find' : \d{3}(?=\,) and for 'Replace' : .$0 which finds the three numbers before the comma and adds the point, but does so with 3-digit numbers as well (.899,56), but of course they should remain unaffected.

can anyone help me out ?

 

rené bosch, graphic designer

netherlands

This topic has been closed for replies.
Correct answer m1b

Hi René, try this:

(\d{1,3})(\d{3},\d{2}\b)

 change to:

$1.$2

Note: assumes no number is higher than 999.999,99. 

2 replies

Peter Kahrel
Community Expert
Community Expert
December 18, 2022

Just for completeness' sake, to add to Mike's query, here's one that inserts dots in any length number:

Find: (\d)(?=(\d\d\d)+,)
Replace: $1.

 

m1b
Community Expert
Community Expert
December 18, 2022

Nice! I don't know why but I just never think of using recursion in grep. Perfect example. 
- Mark

Peter Kahrel
Community Expert
Community Expert
December 18, 2022

Sorry for calling you Mike, Mark!

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
December 18, 2022

Hi René, try this:

(\d{1,3})(\d{3},\d{2}\b)

 change to:

$1.$2

Note: assumes no number is higher than 999.999,99. 

Participating Frequently
December 18, 2022

brilliant m1b ! it works perfectly.

thanks for your quick response.

 

rené bosch, graphic designer

netherlands