Regular Expression Search Challenge In this challenge you will use the file regex_search_challenge_student.py to: Regular Expression Search Challenge Using the Python string below to perform a search...




Regular Expression Search Challenge In this challenge you will use the file regex_search_challenge_student.py to: Regular Expression Search Challenge 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’’’ 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 Assign the regular expression to a variable named pattern Using the find all() method from the re package determine if there are occurrences in search_ string Assign the outcome of the find all() method to a variable called match1 If match1 is not None: 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 not match’ Check It! LAST RUN on 12/9/2017, 7:28:26 PM Check 1 failed Output: regular[ -:&]expression matched Expected: regular[ -:&]expression matched with results=['regular expression', 'regular expression', 'regular-expression', 'regular: expression', 'regular& expression'] Write a regular expression that will find all occurrences of: regular expression regular- expression regular: expression regular& expression In the string: This is a string to search for a regular expression like regular expression or regular-expression or regular :expression or regular& expression Assign the regular expression to a variable named pattern Using the find all() method from the re package determine if there are occurrences in `search_ string` Assign the outcome of the find all() method to a variable called match1 If match1 is not None print to the console the pattern used to perform the match, followed by the word 'matched' Otherwise Print to the console the pattern used to perform the match, followed by the words 'did not match'--------------------------------------------------------------------------------------------------------------------------------------- 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''' #1. Write a regular expression that will find all occurrence  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 find all() method from the re package determine if there are occurrence  in search _string        #4. Assign the outcome of the find all() method to a variable called match1       #5. If match1 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'

May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here