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

How to get only odd and even numbers from a number list with GREP?

Return to Member Forum

  • Author
    Posts
    • #58159
      milkito
      Member

      Hi:

      I need your help. I have a number list since 0001 to 2000, but I just need to extract odd numbers and even numbers, i think that GREP is the right way to do it, but i don`t know how.

      I made my number list in https://textmechanic.com/Genera…..mbers.html

      then I copied an pasted in Indesign, because then I will make a data merge work, where I will put folios, odd above and even below on the same page.

      I will apreciatte your help.

      Thanks and sorry about my english.

    • #58160

      Your English is fine — I bet it's better than my Peruvian (:D)

      The trick is to search for any string of digits, just as long as the very last one is odd (or even). Try this:

      bd+[13579]b

      The b marks a word boundary — that is, when at the left of a 'word character', there may not be another word character; it's the same when it's to the right of a 'word character'.

      d+ is any digit, and the + means you can have one or lots of them.

      [13579] means any single character in this set, so it will match '1' or '3' but not '2' or '?' or 'a'.

      Then another b follows, to ensure this is the very last character in the search string and no other word character follows.

      (A 'word character' is, according to InDesign, 0 to 9, A to Z and a to z, as well as all accented characters, and even the alphabetical characters in Greek, Cyrillic, and many more. It's by definition not anything like a space or punctuation — anything that separates words from each other.)

    • #58164
      milkito
      Member

      Thanks a million Jongware! I can do it at last. that string is great —also its explanation—and it`s the right way to do that task. Long time ago I did the same work but another way less professional of course, but i did not remember it very well. Thanks again to help me to remember how amazing is Indesign and this web page too.

      Thanks again and sorry about my english…just in case…(:D)

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