• Process a title by removing parenthetical content and normalizing characters.

    • Removes content in parentheses
    • Normalizes special quote characters (smart quotes, curly quotes)
    • Replaces hyphens with spaces
    • Normalizes underscores and multiple spaces
    • Trims whitespace

    Parameters

    • title: string

      The title to process

    Returns string

    Processed title

    export function processTitle(title: string): string {
    const withoutParentheses = title.replaceAll(/\s*\([^()]*\)\s*/g, " ");

    return withoutParentheses
    .replaceAll("-", " ")
    .replaceAll("\u2018", "'") // Left single quotation mark
    .replaceAll("\u2019", "'") // Right single quotation mark
    .replaceAll("\u201C", '"') // Left double quotation mark
    .replaceAll("\u201D", '"') // Right double quotation mark
    .replaceAll("_", " ")
    .replaceAll(/\s{2,}/g, " ")
    .trim();
    }