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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, jroy1973
Awide variety of “ apps “ are available to customize devices. which category of app does the word processing software fall into?
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, chaaaa
People with high self-esteem: accept their strengths and weaknesses. believe that failed experiences are failures of their whole self. feel good about who they are only when they reach total success. need positive external experiences to counteract negative feelings that constantly plague them.
Answers: 1
image
Computers and Technology, 23.06.2019 03:30, patience233
Many everyday occurrences can be represented as a binary bit. for example, a door is open or closed, the stove is on or off, and the fog is asleep or awake. could relationships be represented as a binary value? give example.
Answers: 1
image
Computers and Technology, 24.06.2019 16:50, Laylahlettiere
Develop the program incrementally: a) start by reading and displaying each line of the input file to make sure you are reading the data set correctly. b) use the split string method to extract information from each line into a list. print the list to prove that this step is working correctly. d) convert the exam scores to type int and calculate the student’s average. display those items to prove this step is working correctly. e) create a tuple containing the six items for each student (name, exam scores, exam mean). display the tuples to prove this step is working correctly. (optionally, you may want to have the exam scores in a list so your tuple is (name, scores_list, f) append each tuple to a list. display the list to prove this step is working correctly. g) use the sort list method to re-order the tuples in the list. display the list to prove this step is working correctly. h) use a for statement to display the contents of the list as a table (with appropriate formatting). i) use a for statement to calculate the average of all scores on exam #1, then display the results. note that you could have calculated this average within the first loop, but we are explicitly requiring you to do this calculation by looping though your list of tuples. j) add the logic to calculate the average of all scores on exam #2, then display the results.
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 in other subjects: