Skip to main content
Inspiring
Sep 27, 2017 2:39 PM UTC
Answered

Grep to find a range of numbers

Hi,

Can anyone help with a grep query that finds specific ranges of numbers?

I'm trying to find/replace specific ranges so that any number found within that range has its paragraph style changed.

There are four ranges and I've worked out the last two, but am struggling with the first two without affecting higher numbers.

1-45 = ?

46-90 = ?

91-135 =

9[1-9]|1[0-2]\d|13[0-5]

136-180 =

13[6-9]|1[4-9]\d

Anyone know how?

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Obi-wan Kenobi
    Obi-wan KenobiCorrect answer
    Legend
    Sep 27, 2017 8:49 PM UTC

    \b([1-9]|[1-3][0-9]|4[0-5])\b

    \b(4[6-9]|[5-8][0-9]|90)\b

    \b(9[1-9]|1[0-2][0-9]|13[0-5])\b

    \b(13[6-9]|1[4-7][0-9]|180)\b

    (^/)

    4 replies

    amaarora
    Inspiring
    Sep 27, 2017 3:39 PM UTC

    Hi,

    Both of the needed greps look fairly easy to construct.

    I would recommend you read this article https://indesignsecrets.com/topic/using-grep-to-select-a-number-range  and still if you face any difficulty do let us know.

    -Aman

    Translate
    JustyRAuthor
    Inspiring
    Sep 27, 2017 4:18 PM UTC

    Hi, I've wlready been through that one. I can get round the problem by doing find/change grep queries one after the other. So if the first changes every number, the next will change from where I need it to, then the next and so on.

    Thought there would be something more specific to pin down exact ranges.

    Translate
    Obi-wan Kenobi
    Obi-wan KenobiCorrect answer
    Legend
    Sep 27, 2017 8:49 PM UTC

    \b([1-9]|[1-3][0-9]|4[0-5])\b

    \b(4[6-9]|[5-8][0-9]|90)\b

    \b(9[1-9]|1[0-2][0-9]|13[0-5])\b

    \b(13[6-9]|1[4-7][0-9]|180)\b

    (^/)

    Translate