import re
from typing import List
def main(
text: str = "Example of text with several numbers formats \n Los Pollos Hermanos \n 8500 Pan American Fwy NE, \n Albuquerque, NM 87113, USA \n 505-503-4455 \n 234-455-9493 ") -> List[str]:
phoneRegex = re.compile(
r"""(
(\d{3}|\(\d{3}\))? # area code
(\s|-|\.)? # separator
(\d{3}) # first 3 digits
(\s|-|\.) # separator
(\d{4}) # last 4 digits
(\s*(ext|x|ext.)\s*(\d{2,5}))? # extension
)""",
re.VERBOSE,
)
matches = []
for numbers in phoneRegex.findall(text):
matches.append(numbers[0])
return matches
Submitted by henri186 212 days ago
import re
from typing import List
def main(text: str = "Feel free to reach out at +33 1 23 45 67 89 or +33 9 87 65 43 21 if you have any questions or need assistance.") -> List[str]:
# Define a regular expression pattern for French phone numbers
# French phone numbers can be in the format:
# - 01 23 45 67 89
# - +33 1 23 45 67 89
# - 0033 1 23 45 67 89
# Spaces can be replaced by dots or hyphens, and the international prefix is optional.
pattern = r'\b(?:\+33|0033)?\s*[1-9](?:[\s.-]*\d{2}){4}\b'
# Use the re.findall method to find all matches in the input text
phone_numbers = re.findall(pattern, text)
return phone_numbers
Submitted by henri186 212 days ago