I already have a working example of a regex that matches most German street names. However, I recently learned, that the following patterns are possible as well:
How can I build this pattern into my existing Python-regex?:
^(?:[^\W\d_]+\.?|\([^\W\d_]+\.?\))(?:[- '’](?:[^\W\d_]+\.?|\([^\W\d_]+\.?\)))*$
You can just add it with an |
. It also seems that your pattern can be heavily simplified:
^(?:[A-Z] \d|[^\W\d_]{2,}\.?)(?:[- '’][^\W\d_]+\.?)*$