开发者

Javascript .replace works in Firefox but not IE

开发者 https://www.devze.com 2023-03-14 05:30 出处:网络
The following attempt to replace whitespaces with hyphens works in Firefox but not IE: metatext = metatext.replace(/[\\s]/g,\"-\");

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

精彩评论

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