Skip to content

Instantly share code, notes, and snippets.

@tigerhawkvok
Last active May 28, 2021 06:30
Show Gist options
  • Save tigerhawkvok/9db80009b12708dc2c71d2f7beee36f3 to your computer and use it in GitHub Desktop.
Save tigerhawkvok/9db80009b12708dc2c71d2f7beee36f3 to your computer and use it in GitHub Desktop.
Names Regex

Should work with most englishy names of folks - NOT suitable for international use - but just fine for "make sure people locally give me a full name"

The Pattern

^[a-zA-Z'\u00c0-\u01ff]+[ \t]+([a-zA-Z\u00c0-\u01ff]+\.?[ \t]+)?([a-zA-Z\u00c0-\u01ff]+([\-']|[a-zA-Z\u00c0-\u01ff](\. ?)?)?)+(?<!\.|-|')[ \t]*$"

Test Success

  • rayla puppyface
  • sequoia L. doggonator
  • erik x lensherr
  • Goose St. Dog
  • Sokka of St. Watertribe
  • Goose fire-Nation
  • Goose d'Fluff-n-stuff
  • D'arcy Carden
  • X Professor Xavier # I knew someone with the first name "s"
  • Logan S
  • Jérémie O'Co-nor

Test Fail

  • Jérémie O'Co-nor-
  • Jérémie O'Co-nor.
  • Jérémie O'Co-nor'
  • foobar
  • afsd32a
  • asfd 23 asd
  • stuffingthings@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment