简体   繁体   中英

regex unable to allow apostrophe

I am experiencing a strange problem with a regular expression I have already used before. The goal is to allow the user to enter his name, with letters, hyphen, and apostrophes if needed in a php form. My regex is:

 "/^[\w\s'àáâãäåçèéêëìíîïðòóôõöùúûüýÿ-]+$/i"

But... everything is allowed but the apostrophe. Escaping it will not change. Why?

To deal with unicode characters, you can do:

/^[\pN\pL\pP\pZ]+$/

where:

\pN  stands for any number
\pL  stands for any letter
\pP  stands for any punctuation
\pZ  stands for any space

It matches names like:

d'Alembert  
d’Alembert    (note the different apos from above)
Jean-François
O'Connors

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM