Skip to content

Instantly share code, notes, and snippets.

@anaarezo
Last active June 28, 2024 10:04
Show Gist options
  • Save anaarezo/9700a2fec777e80a6638f5fe123380a7 to your computer and use it in GitHub Desktop.
Save anaarezo/9700a2fec777e80a6638f5fe123380a7 to your computer and use it in GitHub Desktop.
Test
export const removeSpecialCharacters = (str?: string) => {
return str
?.replace(/[ÀÁÂÃÄÅ]/g, 'A')
.replace(/[àáâãäå]/g, 'a')
.replace(/[ÈÉÊË]/g, 'E')
.replace(/[^a-z0-9]/gi, ' ');
};
export const getNameInitials = (name?: string) => {
const initials = name?.match(/\b(\w)/g);
if (initials && initials?.length >= 2) {
return initials.slice(0, 2).join('');
} else {
return null;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment