I want to make regex that will recognize official Swiss post addresses. They look like this:
Mr
Hans Schweizer
Gerechtigkeitsgasse 10
3011 Berne
Ms
Susi Frei
c/o Hans Schweizer
Gerechtigkeitsgasse 10
3011 Berne
Mr
Erich Müller
Bahnhofstrasse 4/8
8001 Zurich
So from text that goes something like:
'You should send a letter to:
Mr
Hans Schweizer
Gerechtigkeitsgasse 10
3011 Berne
and tell him all about your last summer...'
Regex should only extract info about address.
I looked at this post: FInd a US street address in text (preferably using Python regex)
And tried to mimic it, but I failed, I could not make it work.
Address should contain:
gender (Herr|Frau|Mrs|Mr|Ms)
name: two or 3 string titled words
street: (strasse|gasse|weg|platz|promenade)
code: int numbers
city: (Zurich|Zürich|Basel|Geneva|Lausanne|Bern|Winterthur|Lucerne|St. Gallen|St.Gallen)
So 95% of streets in Switzerland has suffix "strasse" or "gasse" etc., and Im looking for only some cities (but later I would probably add more).
My problem is that I do not know how to put all this into one regex.
Can you show me how to make regex that will recognize Swiss addresses.