The string to be normalized.
An optional object with options.
OptionalstripPunctuation?: booleanIf true, punctuation and underscores will be stripped. Defaults to true.
A new string with characters in lowercase, without accents, without punctuation (if specified), with single spaces between words, and without leading or trailing whitespace.
// Basic usage (strips punctuation by default)
const normalized = normalizeString("Évènement! de test");
console.log(normalized); // "evenement de test"
// Keeping punctuation
const normalized = normalizeString("Évènement!", { stripPunctuation: false });
console.log(normalized); // "evenement!"
// With accents, punctuation, and uppercase
const normalized = normalizeString("¡Niño!");
console.log(normalized); // "nino"
// Handling multiple types of whitespace and symbols
const normalized = normalizeString("Hello, World!\t100%");
console.log(normalized); // "hello world 100"
Normalizes a string by converting it to lowercase, stripping accents, punctuation (optional), and trimming whitespace.