Hi I’m quite a newbie with javascript so I was wondering how do you remove the words inside the brackets & remove brackets? also I want to remove the words before the colon and then replace the brackets with a comma except for the last word. So for example if the string contains:
language:chinese (29)parody:hyouka (73)character:fuyumi irisu (12)houtarou oreki (12)group:shuudan bouryoku (41)artist:murasaki syu (49)misc:schoolgirl (11)nakadashi (11)acting like a pet (6)
then the output would become
chinese,hyouka,fuyumi irisu,houtarou oreki,shuudan bouryoku,murasaki syu,schoolgirl,nakadashi,acting like a pet
How can I do this with javascript? This is the code and it’s not working
var str = "language:chinese (29)parody:hyouka (73)character:fuyumi irisu (12)houtarou oreki (12)group:shuudan bouryoku (41)artist:murasaki syu (49)misc:schoolgirl (11)nakadashi (11)acting like a pet (6)";
var tags = str.replace(/\s*\(.*?\)\s*/g, ','));
final = tags.replace(/.*(?=:)/i, "");
alert(final);
use [^)]+ to indicate that here is no closing bracket after opening:
even simple: