Regexp for german phone number format

前端 未结 2 1511
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-20 20:13

I try to get phone numbers from string in german format. But I don\'t get it to full run. The input text is a full HTML-Page with lots of content, not only the numbers.

相关标签:
2条回答
  • 2020-12-20 20:42
    [0-9]*\/*(\+49)*[ ]*(\([0-9]+\))*([ ]*(-|–)*[ ]*[0-9]+)*
    

    Check this link: https://regex101.com/r/CAVex8/1

    May introduce some false positives.

    0 讨论(0)
  • 2020-12-20 20:46

    Here is a regex to match all your formats. I would suggest then to replace all unwanted characters and you got your desired result.

    (\(?([\d \-\)\–\+\/\(]+)\)?([ .\-–\/]?)([\d]+))
    

    If you need a minimum length to match your numbers, use this:

    (\(?([\d \-\)\–\+\/\(]+){6,}\)?([ .\-–\/]?)([\d]+))
    

    https://regex101.com/r/CAVex8/143

    updated, thanks for the suggestion @Willi Mentzel

    0 讨论(0)
提交回复
热议问题