Regex for splitting a german address into its parts

前端 未结 6 758
孤街浪徒
孤街浪徒 2021-02-09 18:09

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

6条回答
  •  旧巷少年郎
    2021-02-09 18:31

    try this:

    ^[^\d]+[\d\w]+(\s)\d+(\s).*$
    

    It captures groups for each of the spaces that delimits 1 of the 4 sections of the address

    OR

    this one gives you groups for each of the address parts:

    ^([^\d]+)([\d\w]+)\s(\d+)\s(.*)$
    

    I don't know java, so not sure the exact code to use for replacing captured groups.

提交回复
热议问题