Removes punctuation and special characters from a string. Preserves word characters and spaces only.
The string to clean.
String with punctuation and special characters removed.
export function removePunctuation(input: string): string { return input.replaceAll(/[^\w\s]/g, "");} Copy
export function removePunctuation(input: string): string { return input.replaceAll(/[^\w\s]/g, "");}
Removes punctuation and special characters from a string. Preserves word characters and spaces only.