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

GREP style, i want to add "," in numbers 3454342? 3,454,342

Return to Member Forum

  • Author
    Posts
    • #85770
      Ayman Sayed
      Member

      i want to add “,” in numbers 3454342? 3,454,342

    • #85771
      David Blatner
      Keymaster

      This was discussed on another thread here:

      Add comma to numbers

      The quick answer is there is no “generic” way to do this for thousands, millions, billions, and more… you need to run more than one find/change.

      Also, Peter Spier wrote on the Adobe forums: “First find \d(?=\d{6}\.\d) and change to $0, which will add the comma for the millions, then find \d(?=\d{3}\.\d) and change to $0, to add the comma for the thousands. These expressions work only if there is a decimal number”

      However, there is also a free script here: https://www.id-extras.com/script-to-format-long-numbers

    • #85775

      Hi Guys,

      the following GREP will change

      this:
      1000
      10000
      100000
      1000000
      10000000
      100000000
      1000000000

      to this:
      1,000
      10,000
      100,000
      1,000,000
      10,000,000
      100,000,000
      1,000,000,000

      Find what: \d(?=(\d{3})+)
      Change to: $0,
      

      best
      Kai

      • #85778
        David Blatner
        Keymaster

        Oh my gosh, that’s great! I stand corrected. Thank you, Kai.

      • #85788
        Matt Isaac
        Participant

        This doesn’t work for any number that goes past the thousands place followed by the end of a story

      • #85789

        That is true, because the end of the story is not a boundary. You can fix this temporarily, if you insert a space or a return at the end of the story and remove it later. Of course, this will not work for a grepstyle, but in this special case here, FC is needed.

        Kai

    • #85786

      In Germany we want to have sometimes 10,000 , but not 1000

      In this case you could write: (?<=\d)\d(?=\d{3})|\d(?=(\d{3}){2,})

      Separate telefonnumbers in pairs of two: \d(?=(\d{2})+)

      If there is a separator between the numbers, e.g. a “/”, sometimes this can be a solution: \d(?=(\d{2})+)|\d(?=/)|/

      Hope this is helpful too :)

      Kai

    • #85878
      Ayman Sayed
      Member

      thanks all very much :)))))) amazing

    • #85969
      Ayman Sayed
      Member

      hello guys
      this grep doesnt work into tables – what can i do?

    • #85970
      Ayman Sayed
      Member
    • #85972

      Did you read the comments above?

      is a word boundary. To make clear, what is excactly a word, there is an article from Marc Autret: https://www.indiscripts.com/post/2011/09/what-exactly-is-a-word
      So the GREP will not work at the end of a story. Since every cell behaves like a story, the GREP will fail.

      Solution
      Do it with 3 steps!

      1. Insert something that could be a boundary
      Find what: \d\Z
      Change to $0~<

      2. The FC on the numbers
      Find what: \d(?=(\d{3})+)
      Change to: $0~<

      3. Remove the space at the end of the cell (the story)
      Find what: ~<\Z
      Change to: nothing

      If you work with a GREP-Style instead of FC, don’t do step 3!

      best
      Kai

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