1

I have a form which the user has to fill in. A couple of fields are required to have a minimum of 50 characters. I need to stop the user from entering i.e. over 50 full stops, or another letter/number. I've managed to trap the entry of multiple full stops but does anyone know of a JavaScript/jQuery regular expression to find maybe 5 or more of any character in sequence?

Many thanks in advance,

Jason

superjaz1
  • 436
  • 4
  • 11

1 Answers1

0

Try this:

str.match(/(.)\1{5,}/);

This means: match any character, place it in a capturing group 1, and match this group repeating 5 or more times.

Hnatt
  • 5,767
  • 3
  • 32
  • 43