开发者

Javascript .replace works in Firefox but not IE

The following attempt to replace whitespaces with hyphens works in Firefox but not IE:

metatext = metatext.replace(/[\s]/g,"-");

Neither do the foll开发者_运维技巧owing alternative attempts work in IE:

metatext = metatext.replace(/[\s+]/g,"-");

metatext = metatext.replace(/[ ]/g,"-");

Insights appreciated.


This is probably considered a messy solution, but you could probably try whichever of these you need.

http://phpjs.org/functions/str_ireplace:524
http://phpjs.org/functions/substr_replace:819

str_ireplace is the case-insensitive version of str_replace in PHP.

You may also want to try metatext = metatext.replace(/\s/g, "-");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜