Skip to content

Instantly share code, notes, and snippets.

@stgogm
Last active March 14, 2019 16:01
Show Gist options
  • Save stgogm/32b54c4a5d00e73dedb2 to your computer and use it in GitHub Desktop.
Save stgogm/32b54c4a5d00e73dedb2 to your computer and use it in GitHub Desktop.
Person's name RegExp
/^([a-z\u00C0-\u02AB'´`]{1,}\.?\s?)([a-z\u00C0-\u02AB'´`]?\.?\s?)+$/i
@frank331
Copy link

frank331 commented Mar 14, 2019

Hi, your regex worked pretty well for me amongst others and thus I wanted to thank you; I only have one problem, how can I avoid a single quote character (') to pass the regex?

-Edit:
I've done some research since I'm not so experienced with regex and I think I solved some problems for me with this modified version:
/^((?!.*[\u00D7\u00F7\u01C0-\u01C3])[a-z\u00C0-\u02AF´]{1,}\s?)((?!.*[\u00D7\u00F7\u01C0-\u01C3])[a-z\u00C0-\u02AF'´]?\s?)+$/i;
I have excluded the special caracters × ÷ ǀ ǁ ǂ ǃ that where inside the range of unicode 00C0-02AB, I've extended the latter range until 02AF to match the end of the unicode group and I've removed the single quote character form the first word (in this way I've resolved the case of a single quote passing the regex but for someone may not be good because it blocks the names starting with a single quote).
Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment