开发者

How to deal with Polish Characters while using regex?

开发者 https://www.devze.com 2023-01-03 04:52 出处:网络
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 ]+$/

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号