Last active
June 28, 2024 10:04
-
-
Save anaarezo/9700a2fec777e80a6638f5fe123380a7 to your computer and use it in GitHub Desktop.
Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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