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, "-");
精彩评论