Regular Expressions 101

Community Patterns

Community Library Entry

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