13

I have street name as KRZYWOŃ ANIELI and so what should be my regex to allow this kind of expression. Currently I have simple one which uses /^[a-zA-Z ]+$/

Kindly advise.

Alan Moore
  • 73,866
  • 12
  • 100
  • 156
Rachel
  • 100,387
  • 116
  • 269
  • 365
  • Depends on the language, its flavor of regexps, and how it handles locales. So please add a tag for your language. – Christoffer Hammarström Jun 10 '10 at 14:48
  • Which *programming* language are you using? JavaScript? Perl? Or is it a tool, like `sed` or Notepad++? – Alan Moore Jun 10 '10 at 18:55
  • Never mind; according to your other two attempts at asking this question, the language is PHP. – Alan Moore Jun 10 '10 at 19:01
  • 2
    You should be commenting on answers and commenting of your previous questions regarding this subject. The answers were already given, but you seem to ignore them and not clarify your problem more and keep opening new questions which are basically exactly the same. This is a waste of time. Please clarify how the given answers were insufficient. – BalusC Jun 10 '10 at 19:08

4 Answers4

19

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

Edit: Adjusted regex to better handle whitespace.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
8

\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

Yuri Gor
  • 1,353
  • 12
  • 26
3

I used:

[UserName=[A-Za-zżźćńółęąśŻŹĆĄŚĘŁÓŃ]* [A-Za-zżźćńółęąśŻŹĆĄŚĘŁÓŃ]*\]

for both firstname and surname.

xKobalt
  • 1,498
  • 2
  • 13
  • 19
Emilka
  • 41
  • 1
  • I doubt that this helps, or even works at all. To convince me otherwise please add an explanation of how this works and why it is supposed to help. – Yunnosch Jul 17 '20 at 07:35
  • Sorry, @HubertKubiak "That works." does not add any credibility. That is why I ask for an explanation. – Yunnosch Dec 02 '22 at 16:00
  • @Yunnosch the set covers all polish alphabet letter. I'm not sure what more explanation is needed. – Hubert Kubiak Dec 03 '22 at 10:31
0

Use unicode. see here unicode regular expressions

PurplePilot
  • 6,652
  • 7
  • 36
  • 42
  • I have gone through it but am newbie and so would really appreciate if you guide with the regex expression. – Rachel Jun 10 '10 at 14:39
  • I will try but i am busy at the moment, so if no one else dives in later on this evening. – PurplePilot Jun 10 '10 at 14:44
  • You probably want to replace your character class with the unicode class \p{L} or \p{Letter}: any kind of letter from any language. – dsolimano Jun 10 '10 at 14:45
  • @dsolimani - how can this be done. I have tried using `/^[a-zA-Z \\p{L}\+u]+$/` but it is not working and so am stuck at this. any suggestions. – Rachel Jun 10 '10 at 14:47