javascript - Regex for range 1-50 -


i want need regex create value like:

1-50 

i need regex should allow values 1 50 "-" sign

try following regex: /[1-9]{1}-([0-4]{1}[0-9]{1}|50)/gi
check regexp.test method:

var pattern = /[1-9]{1}-([0-4]{1}[0-9]{1}|50)/gi;  console.log(pattern.test("1-09"));  // true console.log(pattern.test("10-90")); // false console.log(pattern.test("2-49"));  // true console.log(pattern.test("3-51"));  // false 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -