我知道你可以做这样的事情:
var str = "Microsoft has the largest capital reserves of any tech company. Microsoft is located in California.";
str = str.replace(/microsoft/gi, "Apple");
你会得到以下信息:苹果公司拥有所有科技公司中最大的资本储备。 Apple 位于加利福尼亚州。
如何使用全局不区分大小写的方式将 07/08/2011 等字符串更改为 07082011?
我尝试了 str.replace(///gi, "") 的变体,但没有成功。
最佳答案
试试这个:
var input = "07/08/2011";
var output = input.replace(/\//g,""); //output 07082011
关于javascript string.replace 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6626928/