Question: Using the Python string below to perform a search using a regular expression that you create. Search_string = This is a string to search for

Using the Python string below to perform a search using a regular expression that you create.
Search_string = This is a string to search for a regular expression like regular expression or regular-expression or regular:expression or regular&expression
In this challenge you will use the file regrex_search_challange_student.py to:
1. Write a regular expression that will find all occurrences of:
a. regular expression
b. regular-expression
c. regular:expression
d.regular&expression
In search_string
2. Assign the regular expression to a variable named pattern
3. Using the findall() method from the re package determine if there are occurrences in search_string
4.Assign the outcome of the findall() method to a variable called match 1
5. If match 1 is not None:
a. Print to the console the pattern used to perform the match, followed by the word matched
6. Otherwise:
a. Print to the console the pattern used to perform the match, followed by the words did not match
 Using the Python string below to perform a search using a

earch... X import re #The string to search for the regular expression occurrence (This is provided to the student) search string-'This is a string to search for a regular expression like regular expression or regular-expression or regular:expression or regular&expression" sub r, regular . expression #1. Write a regular expression that will find all occurrences of: #a. regular expression b. regular-expression C regular:expression d. regular&expression in search string #2. Assign the regular expression to a variable named pattern pattern = "regular expression" #1. Using the findall() method from the re package determine if there are occurrences in search-s #. Assign the outcome of the findall () method to a variable called match! #2. If match! is not None : H a. Print to the console the pattern used to perform the match, followed by the word 'matched Otherwise: a. Print to the console the pattern used to perform the match, followed by the words 'did no #3. match1 re.sub(pateren,match1,search_string) print(match1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!