Regular Expressions 101

Community Patterns

Regex of name or a firstname

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^((?:(?:[a-zA-Z]+)(?:-(?:[a-zA-Z]+))+)|(?:[a-zA-Z]+))$
/
gm

Description

Format detected:

"Jean" OR "Jean-Pierre" OR "Jean-Marie-Pierre"

Details :

Name[...-Name]

[...-Name] is optional, "Name" can be : a-z or A-Z no accent supported

Submitted by Massinissa CHAOUCHI - 2 years ago