Question: Using Python , write regular expressions to capture the following sets of strings and a function that will match a regex against a string to

Using Python, write regular expressions to capture the following sets of strings and a function that will match a regex against a string to evaluate it.

A) all strings that start at the beginning of the line with an integer and that end at the end of the line with a word; B) all strings that have both the word like and the word duck in them (but not, e.g., words such as likes that merely contain the word like; C) write a pattern that places the first word of a sentence in the complete words of Shakespeare in a file. Deal with punctuation.

I started with

import re

def match(pattern, string): result = False match = re.match(pattern,string,re.IGNORECASE) if match: result = True print("Testing if {} will match {}. Result: {}".format(pattern,string, result)) return match

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!