Regular Expressions 101

Community Patterns

Full Name (Advanced)

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^\s*(?:[a-z]{2,}\.\s*)?(?:[a-]{2,}\s*[a- ]*,\s*[a-]+\s*[a- ]*(?:[a-]\.?\s*){0,3}|[a-]+\s*[a- ]*\s+(?:[a-]\.?\s*){0,3}[a-]{2,}\s*[a- ]*)\s*(?:[a-zñ., ])*$
/
gim

Description

  • Full Name convention either as "firstname lastname" or "lastname, firstname"
  • FirstName must be at least 1character long. LastName must be at least 2characters long.
  • Accepts multiple worded name
  • Optional Middle Initial (with period, up to 2 maximum initials). Placement either middle or last depending on full name convention.
  • Optional Name prefix (with period), Name suffix
  • Allowed alphabet characters only A to Z and Ñ. Allowed symbol are comma and period on valid places only. regex must be set ignore casing.
  • Forgiving extra whitespace typographical error.
  • Safely usable in VBA Regex.
Submitted by cpq.pinoy - 2 months ago (Last modified 2 months ago)