14

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.

4
  • Depends on the language, its flavor of regexps, and how it handles locales. So please add a tag for your language. Commented Jun 10, 2010 at 14:48
  • Which programming language are you using? JavaScript? Perl? Or is it a tool, like sed or Notepad++?
    – Alan Moore
    Commented Jun 10, 2010 at 18:55
  • Never mind; according to your other two attempts at asking this question, the language is PHP.
    – Alan Moore
    Commented Jun 10, 2010 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
    Commented Jun 10, 2010 at 19:08

4 Answers 4

19

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

Edit: Adjusted regex to better handle whitespace.

2
  • @Gumbo, yes, of course. I was trying to tune the regex to what the OP seemed to expect. Commented Jun 10, 2010 at 20:54
  • could you please explain what exactly /u at the end means ?
    – Uladz Kha
    Commented May 27, 2020 at 11:25
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

5

I used:

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

for both firstname and surname.

3
  • 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
    Commented Jul 17, 2020 at 7:35
  • Sorry, @HubertKubiak "That works." does not add any credibility. That is why I ask for an explanation.
    – Yunnosch
    Commented Dec 2, 2022 at 16:00
  • @Yunnosch the set covers all polish alphabet letter. I'm not sure what more explanation is needed. Commented Dec 3, 2022 at 10:31
0

Use unicode. see here unicode regular expressions

4
  • I have gone through it but am newbie and so would really appreciate if you guide with the regex expression.
    – Rachel
    Commented Jun 10, 2010 at 14:39
  • I will try but i am busy at the moment, so if no one else dives in later on this evening. Commented Jun 10, 2010 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
    Commented Jun 10, 2010 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
    Commented Jun 10, 2010 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.