gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 14:39:38 24 4
gpt4 key购买 nike

我怎样才能得到整个句子,而没有第一个单词前面有特殊字符?

例如,如果我有这句话:

 @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 ) ( * );

关于javascript - 获取特殊字符后没有单词的句子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37125226/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com