javascript - How do I use a regular expression to match a fixed-length number with a hyphen in the middle? -


i new regular expressions , wanted know how write regular expression following:

validates string 123-0123456789. numeric values , hyphen should allowed. also, verify there 3 numeric chars before hyphen , 10 chars after hyphen.

the given answers won't work strings more digits (like '012-0123456789876'), need:

str.match(/^\d{3}-\d{10}$/) != null; 

or

/^\d{3}-\d{10}$/.test(str); 

Comments

Popular posts from this blog

jQuery clickable div with working mailto link inside -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -