获取特殊字符后没有单词的句子

Get sentence without a word after special character

本文关键字:句子 没有单 特殊字符 获取      更新时间:2023-09-26

如果没有前面有特殊字符的第一个单词,我怎么能有整个句子?

例如,如果我有这样一句话:

 @jonson where are you?

我只想要这个

  where are you?

如果它像

   where are you @jonson ?

我想要

    where are you?

我知道如何在@后面得到这样的单词:

    var moo = "@jonson where are you?".match(/@([^ ]*)/)[1]; // jonson

希望它能完成,因为我需要得到那句话。感谢

您可以使用字符串替换:

 var moo = "@jonson where are you?".replace(/@'w*/,'');
document.write(moo)

您正在匹配@字符
后面跟着任意数量的任意字字符('w)(*