subject

In this challenge you will use the file regex_replace_challenge_student. py to: 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
Assign the regular expression to a variable named pattern
Using the sub() method from the re package substitute all occurrences of the 'pattern' with 'substitution'
Assign the outcome of the sub() method to a variable called replace_result
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’’’
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
The Python string below is used for substitution substitution="regular expression"
Using the sub() method from the re package substitute all occurrences of the ‘pattern’ with ‘substitution’
Assign the outcome of the sub() method to a variable called replace_result
Output to the console replace_results
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 occurrances 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 string to use for subsitution (This is provided to the student)
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_result
#5. Output to the console replace_results

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 16:00
Page orientation can be either landscape or
Answers: 1
question
Computers and Technology, 21.06.2019 22:00
Which of the following statements correctly identifies a problem with sanitization methods? a. methods are not available to remove data ensuring that unauthorized personnel cannot retrieve data.b. even fully incinerated media can offer extractable data.c. personnel can perform sanitization steps improperly.d. stored data is physically etched into the media.
Answers: 1
question
Computers and Technology, 22.06.2019 17:00
What allows you to create a wireless connection among your smart devices
Answers: 2
question
Computers and Technology, 24.06.2019 09:30
Retype the statements, correcting the syntax errors. system.out.println("num: " + songnum); system.out.println(int songnum); system.out.println(songnum " songs"); note: these activities may test code with different test values. this activity will perform two tests: the first with songnum = 5, the second with songnum = 9. see how to use zybooks.
Answers: 1
You know the right answer?
In this challenge you will use the file regex_replace_challenge_student. py to: Write a regular exp...
Questions
Questions on the website: 13722361