Regexp for german phone number format

前端 未结 2 1514
佛祖请我去吃肉
佛祖请我去吃肉 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: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

提交回复
热议问题