Regular Expressions 101

Community Patterns

Flexible Name Matching

1

Regular Expression
Python

r"
(?P<full_name>(?P<fname>[firstname]{3,})\s\w*?(?P<lname>[lastname]{3,}))
"
gmix

Description

Flexible Name Matching

This algorithm will match name-formatted strings to a minimum accuracy of 3 correct characters per value.

Firstname Lastname

will match any of the following:

First Last fname lname fame lame nameF nameL fam meal man men

As is illustrated above, the presented algorithm is very lazy with its matches.

It can easily be altered to have stricter or more nuanced matching conditions. Breaking the name-formatted string down into individual parts allows for greater specificity within regex matches, and allows for handling of obscure of unusual errors and/or typos.

Have fun!

Submitted by Gabriel Gagnon - 3 years ago