Instructions: Using the text file provided, search for three patterns. o US National ID (Social Security
Question:
Instructions:
● Using the text file provided, search for three patterns.
o US National ID (Social Security Number): DDD-DD-DDDD or DDD.DD.DDDD.
o US Phone number: DDD-DDD-DDDD.
o US Postal Code (Zip Code): DDDDD or DDDDD-DDDD
Each D is a single digit (0-9).
The program will ask the user for the name of the file.
● The program will use RegEx objects to search for the provided patterns.
● The program will print out how many of each type of string was found.
Note: You may want to start using a shorter file for testing.
Here one of my python code:
import re
phone_numbers = []
pattern = r"\(([\d\-+]+)\)"
with open("log.txt", "r") as file:
for line in file:
result = re.search(pattern, line)
phone_numbers.append(result.group(1))
print(phone_numbers)
But I need to add in SSN and zip code.
This is the file name that has the ssn, phone number and zip code again.
Python\Lab 11 String Searches - numbers.txt
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill