我正在使用javascript替换功能,但它似乎不适用于顶点:
myText = "This is an apex ' and this is another apex ' ";
myText.replace(/[^A-Za-z0-9]/,''));
这应该跳过顶点('),但它不会!!
知道如何解决这个问题吗?
谢谢!
答案 0 :(得分:2)
如上所述,这只会替换一次,添加g
(全局)修饰符:
myText.replace(/[^A-Za-z0-9]/g, ''));
这将导致:
Thisisanapexandthisisanotherapex
Here是一个更新的小提琴。