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 t
public static void main(String[] args) {
String data = "Name der Strase 25a 88489 Teststadt";
String regexp = "([ a-zA-z]+) ([\\w]+) (\\d+) ([a-zA-Z]+)";
Pattern pattern = Pattern.compile(regexp);
Matcher matcher = pattern.matcher(data);
boolean matchFound = matcher.find();
if (matchFound) {
// Get all groups for this match
for (int i=0; i<=matcher.groupCount(); i++) {
String groupStr = matcher.group(i);
System.out.println(groupStr);
}
}System.out.println("nothing found");
}
I guess it doesn't work with german umlauts but you can fix this on your own. Anyway it's a good startup.
I recommend to visit this it's a great site about regular expressions. Good luck!