Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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'image text in transcribed

Codio Project File Edit Find View Tools Education Help , Node version regex_search... X import re #The string to search for the regular expression occurrence (This i 2 3 4 searchstring:'This is a string to search for a regular expression 6 7 8 9 regular-expression or regular:expression or regular&expression'' #1. write a regular expression that will find all occurrences of: # b. regular-expression aregu tar expression # C regular:expression d. regular&expression in search_string 12 13 #2. Assign the regular expression to a variable named pattern #1. Using the findall () method from the re package determine if the #. Assign the outcome of the findall() method to a variable called #2. If match! is not None: # a. Print to the console the pattern used to perform the match, #3. Otherwise : # a. Print to the console the pattern used to perform the match 15 16 18 21

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

6. Explain the power of labels.

Answered: 1 week ago

Question

5. Give examples of variations in contextual rules.

Answered: 1 week ago

Question

f. What stereotypes were reinforced in the commercials?

Answered: 1 week ago