1

I'm using javascript replace function, but it doesn't seem to work with the apex:

myText = "This is an apex ' and this is another apex ' ";
myText.replace(/[^A-Za-z0-9]/,''));

This should skip the apex ('), but it doesn't!!

http://jsfiddle.net/GMBMt/5/

Any idea how to resolve this?

Thanks!

4

1 回答 1

2

如所写,这只会替换一次出现,添加一个g(全局)修饰符:

myText.replace(/[^A-Za-z0-9]/g, ''));

这将导致:

Thisisanapexandthisisanotherapex

是一个更新的小提琴。

于 2013-09-19T16:28:41.993 回答