From d9da8a3f27c7d9ccfd7df8621a0f34ae207c8f5d Mon Sep 17 00:00:00 2001 From: Derrick Franco Date: Sat, 2 Sep 2017 11:54:22 -0700 Subject: [PATCH] Changed regex to look for more types of phone numbers including those with parenthesis and extra space --- information-extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/information-extraction.py b/information-extraction.py index e545210..47794fc 100644 --- a/information-extraction.py +++ b/information-extraction.py @@ -22,7 +22,7 @@ """ def extract_phone_numbers(string): - r = re.compile(r'(\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\)\s*\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4})') + r = re.compile(r'(\+\d{1,2})?\(?\d{3}\)?[\s.-]?[\s.-]?[\s.-]?\d{3}[\s.-]?[\s.-]?[\s.-]?\d{4}') phone_numbers = r.findall(string) return [re.sub(r'\D', '', number) for number in phone_numbers]