我有一个像
这样的字符串'here is some #tweet from @someone to @somebody-else'
我需要删除以@mentions开头的所有单词(和短语)并返回没有它们的字符串,以便它变为
'here is some #tweet from to'
如何在Javascript中执行此操作?
谢谢!
答案 0 :(得分:4)
var str = 'here is some #tweet from @someone to @somebody-else';
str = str.replace(/\s?@\S+/g, '');
答案 1 :(得分:3)
var s = 'here is some #tweet from @someone to @somebody-else';
s = s.replace(/\s?@[\w-]+/g, "");
//here is some #tweet from to
<强> 样本: 强>