Mobile app version of vmapp.org
Login or Join
Pope1402555

: Using grep to finding long digit series and inserting thin spaces into them On my page i have a table with over 500 rows, in it one column where all cells contain a different numbers, such

@Pope1402555

Posted in: #AdobeIndesign #Grep #IndesignScripting

On my page i have a table with over 500 rows, in it one column where all cells contain a different numbers, such as 55123, 666000, 3000 and 1459000 (figures for sums of money). I would need to insert thin spaces in the numbers for them to be easier to read, according to the following scheme:

Seven digits in a row is changed to:
d ddd ddd (eg 1 459 000, d=digit)

six to:
ddd ddd (eg. 666 000)

five to:
dd ddd (eg. 55 123)

Four to:
d ddd (eg. 3000)

using find/change I am able to find all instances of for example 7 digits in a row with the grep line d{7} but i am lost at having a command for how to "change" using the found numbers and adding a thin space at the right positions.

Is there a way of writing a script or a find/change query for this operation for doing this anywhere in the text (or just the table)? Any tips on this are much appreciated!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Pope1402555

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kimberly620

There is a bug in the matching engine (at least in my indesign) we will fix this first.


Find:

(.)Z
Replace

:
Replace All


Ok now we have a anchor at the end of story. Now for the magic:


Find:

(d)(?=(ddd)+(:|s))

Explanation match any digit followed by any number triplet of digits and : or any whitespace
Replace

~<

Number and thin space
Replace All


And now let us fix end marker back:


Find:

:d
Replace

leave empty
Replace All


Done.

PS: you can try if (d)(?=(ddd)+Z) works, it does not work on my machine.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme