Regular Expressions 101

Community Patterns

People’s Names / Lastnames (unicode supported, not void, not special characters and not only space first )

0

Regular Expression
PCRE (PHP <7.3)

/
^(?!.*[@\.\_\d])[A-Za-z\x{00C0}-\x{00FF}][A-Za-z\x{00C0}-\x{00FF}\'\-]+([\ A-Za-z\x{00C0}-\x{00FF}][A-Za-z\x{00C0}-\x{00FF}\'\-]+)*
/
gmu

Description

Regular expression taken from the following tutorial: https://andrewwoods.net/blog/2018/name-validation-regex/

I added the first part of the expression (?!.*[@._\d]) in order to not allow @ . _ and numbers cause I discovered a little weakness on the original expression.

Thanks to Andrew Woods

Submitted by anonymous - 5 years ago