RegEx for maximum length in JavaScript RegEx for maximum length in JavaScript javascript javascript

RegEx for maximum length in JavaScript


You are missing closing dollar at the end. Correct one is: /^.{6,7}$/


Match the start and the end.

var sixCharsRegEx = /^.{6,7}$/;

Your improved example


you must use end of string symbol $

like this ^.{6,7}$