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 help! Long string of numbers, need to add a space every 7th number

Tagged: ,

Return to Member Forum

  • Author
    Posts
    • #103498
      Jennifer Bulmer
      Participant

      GREP is a foreign language to me…please help!

      Have a document of all numbers, no spaces (1 billion digits of Pi) and now need to add a space every 7th number. How would I do that?

      Thanks in advance!

      3.1415926535897932384626433832795028841971693993751058209749445923078164

      Needs to look like this:

      3.1415926 5358979 3238462 6433832 7950288 4197169 3993751 0582097 4944592 3078164

    • #103499

      Hi Jennifer,
      try to search:
      (\d\.\d{7})(\d{7})(\d{7})(\d{7})(\d{7})(\d{7})(\d{7})(\d{7})(\d{7,})
      replace with:
      $1 $2 $3 $4 $5 $6 $7 $8 $9

      Unfortunately you cannot add the space into more than 9 groups of numbers, so you need to perform a second search and replace for the last group
      search:
      (\d{7})(\d{7})
      replace:
      $1 $2

    • #103501
      Jennifer Bulmer
      Participant

      Thanks Claudio – so do you mean that it will only do 9 groups of 7 at a time? I have 1 billion digits of Pi!

    • #103504

      You have only 9 variables so can separate a maximum of 9 groups

      repeat this search:
      (\d{7})(\d{7})(\d{7})(\d{7})(\d{7})(\d{7})(\d{7})(\d{7})(\d{7,})

      and replace with:
      $1 $2 $3 $4 $5 $6 $7 $8 $9

      as many time as the number is over.

      Maybe someone here has a different solution.

    • #103505
      David Blatner
      Keymaster

      OK, wait… why on earth would you need to put a space between every 7th digit? Not every 10th digit? What mathematical planet are you from? ;-)

      And why pi?! (You may or may not know that the co-host of this web site — me — is also a pi fanatic.)

      Here’s one solution: In the find/change dialog box, choose the GREP tab. Then search for (\d{7}) and replace it with $0

      Then click Change All. That will insert a space after every 7th digit.

    • #103506

      David, you’re right!
      You saved Jennifer’s life :)

      I think that you don’t need the parenthesis () in the search filed, \d{7} should be fine.

    • #103507
      Jennifer Bulmer
      Participant

      Oh beautiful!! Will try that. Thanks to both of you.

      It’s for a client – I believe trying to memorize 1 billion digits of Pi?? Thinks if grouped like phone numbers will be easier to memorize? Mine is not to question, only to provide the results he wants! Lol.

    • #103509
      David Blatner
      Keymaster

      Ah! Yes, that actually does make sense. But all the record-holders in pi-memorization are Asian… I believe it is far easier to memorize digits in Chinese and Japanese. I talk about that in my book The Joy of Pi. Good luck to your client, and to you! :-)

    • #103510
      Jennifer Bulmer
      Participant

      WORKED LIKE A CHARM!!!! THANK YOU THANK YOU!!!

    • #103511
      Jennifer Bulmer
      Participant

      OMG…..not going to believe this…..but now client wants me to put it in groupings like actual phone numbers of 3 and then 4 digits:

      3.141 5926 535 8979 323 8462 643 3832 795 0288 419 7169 399 3751 058 2097 494 4592 307 8164

      Ready to pull my hair out….
      What would the GREP be for that???? Is it even possible??

    • #103514

      Jennifer, you can leave you hair in place…

      Try search for (\d{3})(\d{4}) and replace with $1$2

    • #103530
      Jennifer Bulmer
      Participant

      You guys are Rock Stars. Again, worked like a charm. Happy client!!

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