-2

I need regex for validating alphanumeric String with length of 6 chars. I tried with following regex And done it for allowing alphanumeric chars but don't know how to stop exceeding more than six chars.

var regex = new RegExp("^[a-zA-Z0-9\b]+$");

Fiddle here.

htoniv
  • 1,608
  • 18
  • 37

1 Answers1

1

you just have to add {6} in the end

var regex = new RegExp('[a-zA-Z0-9\b]{6}$'); You can test it out here https://regex101.com/

Wild Widow
  • 2,159
  • 3
  • 19
  • 33