Home > database >  Which regex expression to use for letters like: ë , á , etc
Which regex expression to use for letters like: ë , á , etc

Time:09-27

I'm currently working on my webshop where customers can personalise their products. I currently have a regex expression like this: [^a-zA-Z ] which only allows customers to use regular letters. But when customers have names which includes letters like: ë, ä, ï, etc. they won't be able to use them.

What I need: a regex expression which allows customers only to use regular letters (a-z / A-Z) AND letters like ë, á, ã.

Does anyone know how I can do that?

CodePudding user response:

You can do that by simple adding these characters in group: [a-zA-Zëáã]. This will match all alphabetic characters, including ë, á and ã.

CodePudding user response:

If you want to allow only letter characters, of any language, (but disallow, for example, digits, special chars, etc.) you can use this character class:

\p{L}

This will match any letter. Check out this website: https://www.regular-expressions.info/unicode.html

  • Related