• Cleans and normalizes a string for comparison.

    Parameters

    • text: string

      The string to normalize.

    • caseSensitive: boolean = false

      Whether to preserve case sensitivity.

    Returns string

    The normalized string.

    export function normalizeString(text: string, caseSensitive = false): string {
    if (!text) return "";

    // Replace special characters and normalize spacing
    const replaced = text
    .replaceAll(/[^\w\s]/gi, " ") // Replace special chars with space
    .replaceAll(/\s+/g, " ") // Collapse multiple spaces
    .trim();

    return caseSensitive ? replaced : replaced.toLowerCase();
    }