I need to validate a user-entered string that will be used as the description on a credit card statement to describe a purchase.
Here are the requirements:
- The string must be between 5 and 22 characters long
- It should have at least one letter (uppercase or lowercase)
- Special characters like <, >, \, ' and " are not allowed
- Only ASCII characters can be used
Currently, I have a regex pattern that partially works:
/^(?=.*?[a-zA-Z])[a-zA-Z0-9]{5,22}$/gm
This pattern correctly validates the length and ensures at least one letter is present. However, it restricts all special characters and diacritics instead of permitting only the few that are not allowed. How can I modify it to allow the specified characters?