Journalism Format - v1.1.12
    Preparing search index...

    Function normalizeString

    • Normalizes a string by converting it to lowercase, stripping accents, punctuation (optional), and trimming whitespace.

      Parameters

      • string: string

        The string to be normalized.

      • options: { stripPunctuation?: boolean } = {}

        An optional object with options.

        • OptionalstripPunctuation?: boolean

          If true, punctuation and underscores will be stripped. Defaults to true.

      Returns string

      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"
      // Stripping hyphens and underscores
      const normalized = normalizeString("multi-word_example");
      console.log(normalized); // "multiwordexample"
      // Handling emails (strips @ and .)
      const normalized = normalizeString("email@example.com");
      console.log(normalized); // "emailexamplecom"