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:
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Income Tax Fundamentals 2013
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
31st Edition
1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App