Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

RegEx: Match numbers greater or equal than 1001

I would like to match numbers greater than or equal to 1001(or ‘1001’). I tried the following pattern "^(^[1-9][0-9]{3,4}$)$". It matches from 1000 and above.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

(?!^1000$)^[1-9]\d{3,}$

Short Explanation

  • (?!^1000$) Except the number 1000
  • ^[1-9]\d{3,}$ Match 4 and more length numbers

JavaScript Example

let regex = /(?!^1000$)^[1-9]\d{3,}$/;

console.log(regex.test("1000"));
console.log(regex.test("1001"));
console.log(regex.test("10000"));
console.log(regex.test("99995555"));

See the regex demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading