Full article: https://www.notion.so/ahmedtokyo/First-and-Last-name-validation-for-forms-and-databases-ab29ca4a5d7a4f848375904649b3be6e
This will work pretty well with all world regions.
const NAME_REGEX = /^[a-zA-Z\xC0-\uFFFF]+([ \-']{0,1}[a-zA-Z\xC0-\uFFFF]+){0,2}[.]{0,1}$/
/** Validates a name field (first or last name) */
const isValidName = (name) => NAME_REGEX.test(name)
This will work pretty well with english-like names covering the regions of North America, South America, Western Europe and Australia.
const NAME_REGEX = /^[a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u01FF]+([ \-']{0,1}[a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u01FF]+){0,2}[.]{0,1}$/
This will work pretty well with the MENA Region (North Africa and the middleast, except certian countries that have multiple minor languages.).
const NAME_REGEX = /^[\u0600-\u06FF\u066E-\u06D5\u0750−\u077F]+([ ]{0,1}[\u0600-\u06FF\u066E-\u06D5\u0750−\u077F]+){0,2}$/