Where $? You need a dollar at the end and maybe catch extra gaps.
var title = $(this).find('title').text().replace(/\s*\([^\)]*?\)\s*$/, "");
If the brackets can also be angle brackets, then this can also be the same:
var title = $(this).find('title').text().replace(/\s*(\([^\)]*?\)|\<[^\>]*?\>)\s*$/, "");
source
share