我想保留一个句子的一部分,将它放在这样的函数的 arg 中:
var sen1 = "Hello this is my email"
var final = "this is my email"
我是 Node.js 和 JS 的初学者。我听说过 RegExp 函数,但我不知道如何使用它Hello
从sen1
.
任何人都可以帮助我或建议我这样做吗?
您不需要为此使用 RegEx,您可以简单地为此使用 String 方法replace()
。
语法如下:
"".replace(<What you want to replace>, <by what you want to replace it>)
所以你正在寻找这个:
let sen1 = "Hello this is my email"
let final = sen1.replace("Hello ", "");
console.log(final);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句