Regular Expressions 101

Community Patterns

Last Name, First Name with some extras

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^[(]([a-zA-Z-\s]*)[,](\s)+([a-zA-Z-\s]*)[)]$
/
gm

Description

Restricts the input of the field to the following format: (Last Name, First Name) The parentheses are included as part of the restriction. Additionally, this formatting allows for hyphenated names, first or last names with more than one word (i.e., Mary Beth, Smith-Doe, etc.).

Submitted by Alexa - 2 years ago