RegEx: How can I match all numbers greater than 954?

I tried ^([0-9]\d|\d{4,})$, but did not give the correct result.

+4
source share
6 answers

I will not use a regex for this, since you will end up in an ugly chain of patterns.

However, if you still need or need to use it, you can use the regex as follows:

[1-9]\d{3,}|9[6-9]\d|9[5-9]{2}

Working demo

Regular expression visualization

The idea of ​​this regular expression is as follows:

[1-9]\d{3,}   --> This will match 4 or more digit numbers
9[6-9]\d      --> This will match numbers between 960 to 999
9[5-9]{2}     --> This will match numbers between 955 to 999
                  you could write this pattern as `95[5-9]` to cover 
                  numbers from 955 to 959 if you wish (it up to you)
+13
source

There he is:

([1-9]\d{3,}|9[6-9]\d|95[5-9])

Look in action for regex101 .

And a good chart:

regex diagram

+2
source

:

95[5-9]|9[6-9]\d|[1-9]\d{3,}

:

  • 95[5-9] 955-959
  • 9[6-9]\d 960-999
  • [1-9]\d{3,} > 1000
+2

, ( ):

^(?:
[1-8][0-9]{3,}
|
9 (?:
      [0-4][0-9]{2,}   
    |
      [6-9][0-9]+     
    |
      5 (?:
            [5-9][0-9]*
          |
            [0-4][0-9]+
        )
  )
)$

, .

:

^(?:[1-8][0-9]{3,}|9(?:[0-4][0-9]{2,}|[6-9][0-9]+|5(?:[5-9][0-9]*|[0-4][0-9]+)))$

: ( ). , , .

+2

, . (, DatabaseTime = 12035 ~ = ~ 12 ). , 120 (.. DatabaseTime > 120000), .

RegEx:

[1-9][2-9][0-9]\d{3,}|[1-9]\d{6,}

, , , , regex101.com, : https://regex101.com/r/hG2iU7/28

/ (- ):

  • , , , , , NotePad ++ RegEx.

  • , Regex ( /), , , NotePad ++,
    - Python, regex (, , GREEDY) , , , .

, : , ... , , ? ... , .

+1

\b(?<!\.)0*(?:[1-9]\d{3,}|9(?:[6-9]\d|5[5-9]))(?:\.\d+)?\b

, 954. , 955.62 0001253.125, 00954.999 125.967. regex101

:

(?<!\.) , , . , , 0.957.

e2: 0* ,

(?:[1-9]\d{3,}|9(?:[6-9]\d|5[5-9])) . [1-9]\d{3,} , 1000. | ( ), 9(?:[6-9]\d|5[5-9]) 900s . , - 60-99 55-59.

(?:\.\d+)? - , .? , , .

e2: \b, , . so1337, the769s 960things.

EDIT1: . .

EDIT2: amended marked "e2:"

0
source

All Articles