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, 23.06.2019 20:30
What is the biggest difference between section breaks and regular page breaks
Answers: 1
question
Computers and Technology, 24.06.2019 07:30
John recently worked on a project about various programming languages. he learned that though procedural language programs are useful, they have disadvantages too. what is a disadvantage of programs written in procedural languages? a. programs do not represent data complexity. b. programs take more time to execute. c. programs are prone to security threats. d. programs do not interface with multiple platforms.
Answers: 3
question
Computers and Technology, 24.06.2019 11:00
Under the home tab, where can a user find options to change the bullet style of an outline? in the slides group in the font group in the paragraph group in the drawing group
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
You work in the accounting department and have been using a network drive to post excel workbook files to your file server as you complete them. when you attempt to save a workbook file to the drive, you see the error message: “you do not have access to the folder ‘j: \’. see your administrator for access to this folder.” what should you do first
Answers: 2
You know the right answer?
In this challenge you will use the file regex_replace_challenge_student. py to: Write a regular exp...
Questions
question
Biology, 24.02.2022 20:40
question
Mathematics, 24.02.2022 20:40
question
Mathematics, 24.02.2022 20:40
Questions on the website: 13722362