• 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
    let normalized = text
    .replace(/[^\w\s]/gi, " ") // Replace special chars with space
    .replace(/\s+/g, " ") // Collapse multiple spaces
    .trim();

    if (!caseSensitive) {
    normalized = normalized.toLowerCase();
    }

    return normalized;
    }