0

I have a regex:

/^([\u00c0-\u01ffa-zA-Z]+['-]{0,1}){3,30}$/

Which means I can use 3-30 given characters, but my upper limit doesn't work. Here is the example with 35 characters string:

/^([\u00c0-\u01ffa-zA-Z]+['-]{0,1}){3,30}$/.test('TXTGWDRWHWTXTGSXYEWGUAHZXQCWDRWHWTX');

And it returns true, but should returns false

Stwosch
  • 602
  • 1
  • 7
  • 20

1 Answers1

0

Each one of these length questions are different.
No two are alike.

For this one I'd suggest

/^[\u00c0-\u01ffa-zA-Z]{2,29}[\u00c0-\u01ffa-zA-Z'-]$/.test('TXTGWDRWHWTXTGSXYEWGUAHZXQCWDRWHWTX');

Which, gives a total of 3-30 characters.

console.log( /^[\u00c0-\u01ffa-zA-Z]{2,29}[\u00c0-\u01ffa-zA-Z'-]$/.test('TXTGWDRWHWTXTGSXYEWGUAHZXQCWDRWHWTX') );

Output

false