嗨我是一個JavaScript的新手,所以我想知道你如何刪除括號內的文字&刪除括號?我也想刪除冒號前的單詞,然後用逗號替換括號,除了最後一個單詞。因此,例如,如果字符串包含:刪除括號內的文字
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)
然後輸出將成爲
chinese,hyouka,fuyumi irisu,houtarou oreki,shuudan bouryoku,murasaki syu,schoolgirl,nakadashi,acting like a pet
我如何能做到這一點的JavaScript?這是代碼,它不工作
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);
我加入我的代碼,但它似乎並沒有工作 –