Improved phone regex to handle end with 4 digits and presence of parenthesis.

This commit is contained in:
Mokaddem 2017-04-26 12:41:23 +02:00
parent b60e164380
commit 3ea0924120

View file

@ -16,6 +16,7 @@ def search_phone(message):
content = paste.get_p_content()
# regex to find phone numbers, may raise many false positives (shalt thou seek optimization, upgrading is required)
reg_phone = re.compile(r'(\+\d{1,4}(\(\d\))?\d?|0\d?)(\d{6,8}|([-/\. ]{1}\d{2,3}){3,4})')
reg_phone = re.compile(r'(\+\d{1,4}(\(\d\))?\d?|0\d?)(\d{6,8}|([-/\. ]{1}\(?\d{2,4}\)?){3,4})')
# list of the regex results in the Paste, may be null
results = reg_phone.findall(content)