-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,658
  • 21
  • 40

1 Answers1

2

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,359
  • 3
  • 22
  • 34