简体   繁体   中英

add special characters regex ruby

I have this regex in my model:

/^(?:[^\W_]|\s|[\._@-])*$/u

I want add to this regex this special char:

ñáéíóú

I would like to know how add other charset from other languajes, chino, japanesse, indian...etc. Thank you.

I don't know if Ruby understand that, but you should use unicode properties like:

/^[\p{L}\s\p{N}._@?¿!¡€-]+$/

where

\p{L}   : any unicode letter
\p{N}   : any unicode number

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