@patchworkdev/common
Version:
Patchwork Development Kit
7 lines (6 loc) • 322 B
text/typescript
export function cleanAndCapitalizeFirstLetter(string: string) {
// Remove non-alphanumeric characters and whitespace
const cleanedString = string.replace(/[^a-zA-Z0-9]/g, '');
// Capitalize the first letter of the cleaned string
return cleanedString.charAt(0).toUpperCase() + cleanedString.slice(1);
}