Not able to get Regular Expression in javascript

You need to check for anchors (^ and $ forcing the check at the beginning and end of the string) as well, not just the patterns.


Use with i option to ignore letter case.

See demo

Sample code:

var re = /^\d{4}-[a-z]{4}-\d{5}$/i; 
var str="1234-abcd-12345";
if (re.test(str)) {

Leave a Comment