How to deal with Polish Characters while using regex?
I have street name as KRZYWOŃ ANIELI
and so w开发者_运维问答hat should be my regex to allow this kind of expression. Currently I have simple one which uses /^[a-zA-Z ]+$/
Kindly advise.
Use /^[\s\p{L}]+$/u
(PHP syntax).
Edit: Adjusted regex to better handle whitespace.
\p{L} catches not only Polish letters, but also Russian for example, may be some other too.
If you, like me, need Polish letters only, take this:
[AaĄąBbCcĆćDdEeĘęFfGgHhIiJjKkLlŁłMmNnŃńOoÓóPpRrSsŚśTtUuWwYyZzŹźŻż]
Characters got from wiki
I used:
[UserName=[A-Za-zżźćńółęąśŻŹĆĄŚĘŁÓŃ]* [A-Za-zżźćńółęąśŻŹĆĄŚĘŁÓŃ]*\]
for both firstname and surname.
Use unicode. see here unicode regular expressions
精彩评论