Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Match all numbers greater than 36 using regex? [duplicate]

Tags:

regex

How can I match all numbers greater than 36 to any bigger number?

I tried this expression:

[4-9]\d+|\d{3,}

Problem is this will select all number greater than 40 but I need 37, 38 and 39 as well, How can i achieve that?

NOTE: My query is different: I couldn't understand from there so I asked my own question and my query is 100% different. Being similar in some ways is another thing than being duplicate. Peace out.

like image 383
Mansoor Akram Avatar asked Oct 18 '15 08:10

Mansoor Akram


2 Answers

Simply adding 3[7-9] (to match 37, 38, 39) will work:

3[7-9]|[4-9]\d+|\d{3,}

UPDATE

To prevent matching numbers like 0001:

3[7-9]|[4-9]\d+|[1-9]\d{2,}
like image 165
falsetru Avatar answered Oct 14 '22 11:10

falsetru


The simplest solution:

37|38|39|[4-9]\d+|\d{3,}

or to exclude numbers starting with 0:

\b(37|38|39|[4-9]\d+|(?!0)\d{3,})\b
like image 44
w.b Avatar answered Oct 14 '22 10:10

w.b