我的代码中有这个字符串。我想Window: String
使用正则表达式从下面的字符串中删除。
"function(param: Int, Window: String, param1: String, Window: String)"
它应该像
"function(param: Int, param1: String)"
如果是,"function(Window: String)"
那么应该是"function()"
有谁知道如何做到这一点 ?
你可以做
let str = 'function(param: Int, Window: String, param1: String, Window: String)';
console.log(str.replace(/(, )?Window: String/g, ''));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句