Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

grouping numbers by GREP

Return to Member Forum

  • Author
    Posts
    • #63870
      boris the typo
      Participant

      I am trying to separate thousands by using GREP. I'm not good enough at it, so i thought I'd ask the experts:

      We are using comma , for decimals of metric (ISO) units, and period . for US units, sometimes in the same table.

      Space is used as thousand separator:

      123,4
      1 234,5
      123 456 (rarely more than six in a row)

      But decimals are only grouped when five or more (rarely more than six).

      0,0001
      0,000 01

      Combos appear, but this would be worst case, and likely never to happen (but …):

      1 234 567 890,123 456

      units are not set by the dimension, but in the table heading, so we don't have to bother about them.

      The data in, is not thousand-separated. Sometimes it's a text file, sometimes an excel sheet. Getting the thousand separation “automagic” would be neat.

      So, I am trying to apply a character style on the figure to the right of the space, with a positive tracking, creating a nice space:

      When using this expression: (?<!,)d(?=d{3}($|,) get these results

      1 234
      12 345
      123 456
      1234 567
      12345 678
      123456 789
      … so it works up to and including six integers

      1 234,123
      12 345,123
      123 456,123
      1234 567,123
      … so it works up to and including six integers (also when thre are four decimals)

      But with: (?<!,)d(?=d{3}($|,)|(?<!,)d(?=d{6}($|,))) it goes

      0,12 345
      1 234
      12345
      123456
      1234567
      123,12 345
      … it stops working

      I have tried several expressions and have not managed to fix it, but I've done other neat things with automatic fractions and tolerances styling … but this beats me, despite I do have a pocket reference on grep.

      Any ideas? Or should I just do my homework? :-)

Viewing 0 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads