• Normalize a string for matching operations.

    • Converts to lowercase
    • Removes hyphens and special characters (keeps only word chars and spaces)
    • Collapses multiple spaces to single space
    • Trims whitespace

    Parameters

    • str: string

      The string to normalize

    Returns string

    Normalized string suitable for title matching

    export function normalizeForMatching(str: string): string {
    return str
    .toLowerCase()
    .replaceAll("-", "")
    .replaceAll(/[^\w\s]/g, "")
    .replaceAll(/\s+/g, " ")
    .replaceAll("_", " ")
    .trim();
    }