Henri wrote:
any idea why a regexp-based trim function would work fine in firefox but
not in ie?
code is
String.prototype.trim = function() {
re = /\s*$/g;
return this.replace(re, "");
}
it trims trailing spaces. I've tried various regular expressions. The
point is: this works in firefox (where supplied strings are trimed fine)
but ie (always ie -oh i wish ie didn't even exist!) the function returns
an unchanged string.
WFM in
- Mozilla/4.0 (compatible; MSIE 4.01; Windows NT 5.0)
- Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; .NET CLR 2.0.50727)
- Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1; .NET CLR 2.0.50727)
- Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 2.0.50727)
- Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)
However, you should declare `re' with `var' (or remove it), `*' is
inefficient (use `+' instead), and `g' is unnecessary (your expression is
anchored).
HTH
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16