Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started