Reputation: 21
I have a webcall that give me the following callback as string:
ZIPCODE | CITY | STREET NR | , |Phone Number with (Tel.) on the beginning
EXAMPLE1 :
83661 Lenggries Marktstr. 14, Tel. 08042 91860
I would like to ask the regex professionals if it would be possible to break them down into groups? My best try at the moment is:
([0-9]{5})(\s[a-zA-Z].+)(\s[a-zA-Z].+)(\s.*)(\s.[0-9]*)(\s.[0-9]*)
which results in:
This works for the sample above but is not a stable regex, for example:
EXAMPLE2:
83620 Feldkirchen-Westerham Aiblinger Str. 7, Tel. 08063 8562
results in:
Maybe somebody can help me with this problem, I have no idea how to solve it. The data cannot be given in any other format either. :(
regards and thanks in advance Matthias
Upvotes: 2
Views: 470
Reputation: 1
Check it in Python!
^[ \-0-9a-zA-ZäöüÄÖÜß.]+?\s+(\d+(\s?[a-zA-Z])?)\s*(?:$|\(|[A-Z]{2})\s+(\d{5})\s*(.+)
if you want to see the demo! Click here
Upvotes: 0