You can download this code by clicking the button below.
This code is now available for download.
This function is used to extract phone numbers from a given text. It uses regular expressions to match common phone number formats.
Technology Stack : csv, re
Code Type : Function
Code Difficulty : Intermediate
import csv
import re
def extract_phone_numbers(text):
pattern = re.compile(r'\b\d{3}[-.\s]?\d{3}[-.\s]?\d{4}\b')
phone_numbers = pattern.findall(text)
return phone_numbers