-1

I try to make a regex that accepts any input combination, but the condition is text must be of less than 200 characters.

for example

'123ababb' => valid
'abbd$5%' => valid

I used the following regex but it doesn't match for any special character.

[a-zA-Z0-9 .,']{0,200}

Umutambyi Gad
  • 4,082
  • 3
  • 18
  • 39
Pranay kumar
  • 1,983
  • 4
  • 22
  • 51

1 Answers1

1

using regex, in this case, is not a good option because usually, we use to regex to create a special pattern or find something in a string.

in your case, I suggest using .length

for example:

let your_string = 'anyStringYouWant';
consloe.log('string length:' , your_string.length);
if (your_string.length > 200) {
    console.log('string length is bigger than 200')
}
Mehrab HP
  • 51
  • 7