`match` 结果的 `alert` 显示逗号​​分隔的字符串;如何只获得第二部分?

`alert` of `match` result shows comma-separated string; how to get only the second part?

解析时

<title>I have a cat</title> <div class="chat_message_wrapper chat_message_right">

var re_title = new RegExp("<title>(.*?)</title>");
var content = xmlhttp.responseText;
// var title = re_title.exec(content);
var title = content.match(re_title);

// title = strip(title);
alert(title);

出于某种原因,我在警报中收到此消息:

<title>I have a cat</title>,I have a cat

如何只得到“我有一只猫”的部分?

match 方法 returns 一个数组,第一个是完全匹配,其他元素是捕获组。由于您有一个捕获组,因此您需要从索引 1 处的数组中获取值:

 title[1]