我正在尝试解析原始推文字符串以匹配@username 和#topic 部分,我能够匹配它们,但我不熟悉如何包装它们。
我的代码:
"Hey @someotheruser this is a tweet about #topic1 and #topic1".replace(/(^|)@(\w+)/, '<span class="mention">?result of match?</span>');
"Hey @someotheruser this is a tweet about #topic1 and #topic1".replace(/(^|)#(\w+)/, '<span class="hash">?result of match?</span>');
所以我的问题是:我如何得到我的比赛结果,并用跨度包装它?