Tell me how to check the number from 2 to infinity?

^category/page-(?P<page>[0-9]+)$ 

That is, if in the line page-0 or page-1 then this should not fit the regular schedule.

    1 answer 1

    Use

     ^category/page-(?![01]$)(?P<page>[0-9]+)$ ^^^^^^^^^ 

    See the regular expression demo .

    If the numbers of type 001 should be filtered, add 0* -> (?!0*[01]$) .

     ^category/page-(?!0*[01]$)(?P<page>[0-9]+)$ ^^ 

    Another demo .

    A template (?![01]$) is a forward preview block that does not return a match if immediately after the current position (ie, after the hyphen) is 0 or 1 ( [01] ), followed immediately by the end of the line ( $ ). 0* finds zero and more characters 0 .

    • as an option ([3-9]|\d{2,}) - teran
    • one
      Thank you master, half an hour suffered ... - Vladimir
    • @Wiktor can you do something without a lead in front? - Vladimir
    • I seem to have already written about this. Demo - regex101.com/r/l6hTrv/2 - Wiktor Stribiżew
    • @ WiktorStribiżew I asked a question earlier than you wrote. Thank you, everything was as it should be. - Vladimir