Question: USING PYTHON. 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 PYTHON.
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 findall() method from the re package determine if there are occurrences in search_string
Assign the outcome of the findall() 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
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 findall() method from the re package determine if there are occurrences in `search_string`
Assign the outcome of the findall() 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'
COMPLETE THE CODE BELOW IN PYTHON:
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 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
#1. Using the findall() method from the re package determine if there are occurrences in search_string #. Assign the outcome of the findall() method to a variable called match1 #2. If match1 is not None: # a. Print to the console the pattern used to perform the match, followed by the word 'matched' #3. Otherwise: # a. Print to the console the pattern used to perform the match, followed by the words 'did not match'

C Codio Project File Edit Find View Tools Education Help ,Node version Project Index (static) regex_search..X import re #The string to search for the regular expression occurrence (This is provided to the stu 2 3 4 5 6 7 8 9 search stringThis 1s a string to search for a regu lar expression Lke regular expres regular-expression or regular:expression or regular&expression #1. write a regular expression that will find au occurrences of: # a. regular expression # b. regular-expression # c. regular:expression # d. regular&expression 12 13 in search_string #2. Assign the regular expression to a variable named pattern #1. Using the findall() method from the re package determine if there are occurrences i #. Assign the outcome of the findau () method to a variable called match! #2. If match! is not None: # a. Print to the console the pattern used to perform the match, followed by the wor #3 . Otherwise : # a. Print to the console the pattern used to perform the match, followed by the wor 15 20 21 C Codio Project File Edit Find View Tools Education Help ,Node version Project Index (static) regex_search..X import re #The string to search for the regular expression occurrence (This is provided to the stu 2 3 4 5 6 7 8 9 search stringThis 1s a string to search for a regu lar expression Lke regular expres regular-expression or regular:expression or regular&expression #1. write a regular expression that will find au occurrences of: # a. regular expression # b. regular-expression # c. regular:expression # d. regular&expression 12 13 in search_string #2. Assign the regular expression to a variable named pattern #1. Using the findall() method from the re package determine if there are occurrences i #. Assign the outcome of the findau () method to a variable called match! #2. If match! is not None: # a. Print to the console the pattern used to perform the match, followed by the wor #3 . Otherwise : # a. Print to the console the pattern used to perform the match, followed by the wor 15 20 21
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
