Mr. and Ms. Smith

Report a typo

Let's try to differentiate between some kinds of honorifics. Write a regular expression in the variable template in such a way that it would match the following strings:

  • Mr Smith
  • Mr. Smith
  • Ms Smith
  • Ms. Smith

Note that your template should not match any other strings (for example, Dr. Smith).

Write a program in Python 3
import re

# define regex template
template = ''
___

Create a free account to access the full topic