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

Find a number bigger than

Return to Member Forum

  • Author
    Posts
    • #75884
      Delfim Machado
      Participant

      How do I find a document number that is greater than 2000 (bigger than)? I have an index that has changed and need to change the numbering .

    • #75891
      Justin Sligh
      Member

      Delfim,

      If you need to find numbers 2001 and greater, the following grep will work.

      If you explain the nature of the change or provide an example, maybe we can provide an alternate solutions.

      2\d\d[1,2,3,4,5,6,7,8,9]|[3,4,5,6,7,8,9]\d\d\d?\d+

      The first part before the pipe looks for a number 2001-2999 and the second portion looks for 3000-any. This is assuming no additional marks or delineators.

    • #75902
      Anonymous
      Inactive

      This includes 2000

      \<\d\d{3,99}

      This excludes 2000

      (?!2000)\<\d\d{3,99}

    • #75903
      Anonymous
      Inactive

      Oops should have tested that further – that doesn’t work that well.

    • #75904
      Anonymous
      Inactive

      This excludes 2000

      (?![01]|2000)\<\d\d{3,99}

    • #75905
      Anonymous
      Inactive

      I don’t know why I made the end bit that complicated, it can be just (?![01]|2000)\<\d\d+

    • #75906
      Justin Sligh
      Member

      I love the smell of GREP in the morning.

    • #75909
      Masood Ahmad
      Participant

      I too can smell the same here, Justin.

      Sorry for interrupting here in between the two giants of knowledge.

      However, when I tested the codes by Eugene, I found that it is searching all the numbers whether greater or lesser than 2000.

      “This includes 2000
      \<\d\d{3,99}
      Result: It is searching for the numbers greater or equal to four digits whether it is 1000 or 1999 or 2000 etc.

      This excludes 2000
      (?!2000)\<\d\d{3,99}
      Result: This is same, searching for the numbers greater or equal to four digits excluding 2000 only

      This excludes 2000
      (?![01]|2000)\<\d\d{3,99}
      (?![01]|2000)\<\d\d+
      Result: This code is also looking for the numbers greater or equal to four digits. But the problem with the code is that it is also ignoring the numbers if the starting digit is one for example: 15860, 192453. Although these are greater than 2000.”

      Whereas the code by Justin 2\d\d[1-9]|[3-9]\d\d\d?\d+ proves to be somewhat closer to the query raised by Delfim.
      but it has the same problem as listed above. It is not searching for the numbers if it is starting at one for example 123456, 15860, 192453 etc.

      The code needs tweaking.

    • #75910
      Anonymous
      Inactive

      Yes indeed, I can’t seem to figure it out just yet, I think we need a higher power.

      Might not be possible with GREP, but maybe as script.

    • #75912

      Comparing numbers for size with GREP is a dark art and best avoided whenever possible. Justin is right: trying to solve your problem (barely mentioned so far; but there are scripts to adjust numbers!) with GREP leads to the adage “now you got two problems”.

      Anyway, I’ll have a go at it, just for the fun of it :D

      (?![012]\d{3})\d{4,}

      This find series of 4 digits or more, but if there are only 4 it will ignore them if they start with “0”, “1”, or “2”. The addition of “0” in this sequence will make it ignore “0123” as well – you may consider that a bonus.

    • #75916
      Masood Ahmad
      Participant

      Jongware, I knew that you’ll join this post. It is something new and interesting and possibly not possible with GREP. As Eugene pointed out, can this be achieved with a JavaScript?

    • #75920
      Masood Ahmad
      Participant

      It seems, we are closer to it after tweeking the Jongware’s code:
      (?![0-1999]\d{3})\d{4,}

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