Python Regular Expression Help.
Go to solution
Solved by dannytech357,
This may be a little closer to what you want:
(M(?:r|rs|s)(?:\.?) (?:[A-Za-z\s]*?))(?:\s[a-z]|\n|$|\.)
It will also match Mr, Mrs, and Ms and read until it finds a space followed by a lowercase character, the end of the line, or the end of the string. It will match everything the way you wanted it to. I also added (?:\.?) to optionally match Mr., Mrs., and Ms., but you can remove that if you don't think you need that
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now