Skip to content

Instantly share code, notes, and snippets.

@erikvullings
Created December 13, 2020 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikvullings/c3d29688c2439654f54dda9ae8434f56 to your computer and use it in GitHub Desktop.
Save erikvullings/c3d29688c2439654f54dda9ae8434f56 to your computer and use it in GitHub Desktop.
Capitalize first names derived from an email address (Dutch)
export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
/** Capitalize first names that are derived from an email, like anne_merel or jan_willem. */
export const capitalizeName = (s: string) =>
/^ij/i.test(s) // names like IJsbrand
? s.replace(/^ij/i, 'IJ')
: /_/.test(s) // names like jan_willem
? s.split('_').map(capitalize).join('-')
: capitalize(s); // other names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment