I have a string like
'here is some #tweet from @someone to @somebody-else'
and I need to remove all the words (and-phrases) that start with @mentions and return the string without them, so that it becomes
'here is some #tweet from to'
How to do that in Javascript?
Thank you!
var str = 'here is some #tweet from @someone to @somebody-else';
str = str.replace(/\s?@\S+/g, '');
var s = 'here is some #tweet from @someone to @somebody-else';
s = s.replace(/\s?@[\w-]+/g, "");
//here is some #tweet from to
DEMO:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.