Skip to content

Instantly share code, notes, and snippets.

@0OZ
Last active June 20, 2024 13:51
Show Gist options
  • Save 0OZ/447ecddcbbe8e9bef546701822fb8cde to your computer and use it in GitHub Desktop.
Save 0OZ/447ecddcbbe8e9bef546701822fb8cde to your computer and use it in GitHub Desktop.
Regex for German street names

Regular Expressions

((Ober|Unter den|An |Im |Platz |Berg |Am |Alt\-).+|(?:([A-Z][a-zäüö-]+){1,2})).([Cc]haussee|[Aa]llee|[sS]tr(\.|(a(ss|ß)e))|[Rr]ing|berg|gasse|grund|hörn| Nord|graben|[mM]arkt|[Uu]fer|[Ss]tieg|[Ll]inden|[Dd]amm|[pP]latz|brücke|Steinbüchel|Burg|stiege|[Ww]eg|rain|park|[Ww]eide|[Hh][oö]f|pfad|garten|bogen|passage).+?(\d{1,4})([a-zäöüß]+)?(\-?\d{1,4}[a-zäöüß]?)?

Note: the first letter must be capitalized and there must be a house number

//city with zip code

(?<![\.\d])(\d{4,5})\b\W+?(\p{L}+?)\b

feel free to improve the Regex

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@0OZ
Copy link
Author

0OZ commented Apr 8, 2021

Example:

Leibnizstr. 12

[
  [
    {
      "content": "Leibnizstr. 12",
      "isParticipating": true,
      "groupNum": 0,
      "groupName": null,
      "startPos": 0,
      "endPos": 14
    },
    {
      "content": "Leibni",
      "isParticipating": true,
      "groupNum": 1,
      "groupName": 1,
      "startPos": 0,
      "endPos": 6
    },
    {
      "content": "",
      "isParticipating": false,
      "groupNum": 2,
      "groupName": 2,
      "startPos": -1,
      "endPos": -1
    },
    {
      "content": "Leibni",
      "isParticipating": true,
      "groupNum": 3,
      "groupName": 3,
      "startPos": 0,
      "endPos": 6
    },
    {
      "content": "str.",
      "isParticipating": true,
      "groupNum": 4,
      "groupName": 4,
      "startPos": 7,
      "endPos": 11
    },
    {
      "content": ".",
      "isParticipating": true,
      "groupNum": 5,
      "groupName": 5,
      "startPos": 10,
      "endPos": 11
    },
    {
      "content": "",
      "isParticipating": false,
      "groupNum": 6,
      "groupName": 6,
      "startPos": -1,
      "endPos": -1
    },
    {
      "content": "",
      "isParticipating": false,
      "groupNum": 7,
      "groupName": 7,
      "startPos": -1,
      "endPos": -1
    },
    {
      "content": "12",
      "isParticipating": true,
      "groupNum": 8,
      "groupName": 8,
      "startPos": 12,
      "endPos": 14
    }
  ]
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment