Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 (10 points): highlight (pattern, string) Write a Python function named highlight (), which takes a raw string specifying a regex pattern as the

image text in transcribed

Problem 1 (10 points): highlight (pattern, string) Write a Python function named highlight (), which takes a raw string specifying a regex pattern as the first argument, called pattern, and a string as the second argument, called string. The function will compile pattern and apply the compiled pattern to string. If a match is found, then the function will return a string in which the matched substring of string is enclosed in angle brackets. If no match is found, the function should return None. For example, suppose that: pattern = r'[a-zA-Z]\d' string "ShepardN7" returns: "Shepard" Test Cases: pattern = r' \bbook\B' strings ["bookstore", "booking", "textbooks", "'returned books'", "audiobook"]<7>

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

How wide are Salary Structure Ranges?

Answered: 1 week ago