Regex for splitting a german address into its parts

Posted by Christian on Stack Overflow See other posts from Stack Overflow or by Christian
Published on 2012-03-25T20:14:19Z Indexed on 2012/03/26 17:29 UTC
Read the original article Hit count: 400

Filed under:
|
|
|
|

Good evening,

I'm trying to splitting the parts of a german address string into its parts via Java. Does anyone know a regex or a library to do this? To split it like the following:

Name der Straße 25a 88489 Teststadt
to
Name der Straße|25a|88489|Teststadt

or

Teststr. 3 88489 Beispielort (Großer Kreis)
to
Teststr.|3|88489|Beispielort (Großer Kreis)

It would be perfect if the system / regex would still work if parts like the zip code or the city are missing.

Is there any regex or library out there with which I could archive this?

EDIT: Rule for german addresses:
Street: Characters, numbers and spaces
House no: Number and any characters (or space) until a series of numbers (zip) (at least in these examples)
Zip: 5 digits
Place or City: The rest maybe also with spaces, commas or braces

© Stack Overflow or respective owner

Related posts about java

Related posts about regex