How to work with Polish characters when using regular expressions?

I have a street name like KRZYWOŃ ANIELI , and therefore there must be my regular expression to allow this expression. I currently have a simple one that uses /^[a-zA-Z ]+$/

Please advise.

+4
source share
3 answers

Use /^[\s\p{L}]+$/u (PHP syntax).

Edit: adjusted regex to better deal with spaces.

+10
source

\ p {L} catches not only Polish letters, but also, for example, Russian, may be different.

If you, like me, need only Polish letters, do the following:

 [AaĄąBbCcĆćDdEeĘęFfGgHhIiJjKkLlŁłMmNnŃńOoÓóPpRrSsŚśTtUuWwYyZzŹźŻż] 

Characters derived from the wiki

0
source

Use unicode. see here unicode regular expressions

-1
source

Source: https://habr.com/ru/post/1312454/


All Articles