Helpful Information
 
 
Category: Regex Programming
Regex name test

hi

im trying to create a regex pattern for a name field. Basically, I want to throw an error only if the user types in certain strings



!?<>


otherwise, even if the field is empty, the field should be true.

this is the pattern i created,but it does not seem to work if I have a empty space in the field:




return /^[a-zA-Z']{1,40}$/.test(str);

So you don't want ! ? < > in the field? Up to 40 characters?

/^[^!?<>]{1,40}$/
That checks if it is valid (as opposed to checking if it's invalid).










privacy (GDPR)