Hello,
I want to match strings like
reutlingen
tübingen
Glashütte-Luchau
Glashütte - Luchau
Kurort Rathen
Weißbach b Königsbrück
Knappensee-Groß Särchen
Jämlitz-Klein Düben
Flughafen Leipzig/Halle
Stolzenhain a d Röder
So, allowed charachters are a to z, A to Z, ä, ü, ö, /, - and space (no other white space character!)
If the string holds any other characters or digits, there should be no match!
I thought character classes were the correct way, but I think I'm going the wrong direction...
Thanks for help!
Matching strings with RegExp
Moderator: General Moderators
-
visionmaster
- Forum Contributor
- Posts: 139
- Joined: Wed Jul 14, 2004 4:06 am
-
visionmaster
- Forum Contributor
- Posts: 139
- Joined: Wed Jul 14, 2004 4:06 am
Re: Matching strings with RegExp
Oops, find it out. It works like this:
^[-\\\sA-Za-zäöü]+$
Any other suggestions?
^[-\\\sA-Za-zäöü]+$
Code: Select all
if (preg_match('/^[-\\\\\\sA-Za-zäöü]+$/si', $subject)) {
} else {
}- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US