Reference no: EM132330136
Regular Expression Replace Challenge
In this challenge you will use the file regex_replace_challenge_student.py to:
1. Write a regular expression that will replace all occurrences of:
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
2. Assign the regular expression to a variable named pattern
3. Using the sub() method from the re package substitute all occurrences of the 'pattern' with 'substitution'
m Assign the outcome of the sub() method to a variable called replace_results 4 Output to the console replace_results
Regular Expression Replace Challenge
The Python statement containing the string to search for the regular expression occurrence is below.
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
The Python string below is used for substitution substitution="regular expression"
3. Using the sub() method from the re package substitute all occurrences of the 'pattern' with 'substitution'
4. Assign the outcome of the sub() method to a variable called replace_results
5. Output to the console replace_results