Re: How Does JavaScript Call Forth CSS??



On May 1, 2:18 pm, Thomas 'PointedEars' Lahn <PointedE...@xxxxxx>
wrote:
dhtml wrote:

turns out that non-capturing parentheses are not supported before JavaScript
1.5, JScript 5.5, ECMAScript Ed. 3. Use them and your script will break in
IE before version 5.5, for example.

OK. It won't work in IE 5.0. A lot of stuff won't e.g. apply(),
push().


A capturing group stores the whitespace:
(\\s+|$)

A non-capturing group does not:
(?:\\s+|$)

True, after a fashion.

It is less efficient to use a capturing group.

Nonsense. The tiny amount of memory saved by not storing the backreference
is bought with the tiny amount of runtime that is required more to parse the
non-capturing expression.


No, it is somewhat faster to use a non-capturing group.

(function() {
var token = "bar",
exp = new RegExp("(^|\\s)"+token+"($|\\s)"),
t= new Date;
for(var i = 0; i < 10000; i++) {
exp.exec("foo bar baz quux");
}
return new Date - t;
})();

(function() {
var token = "bar",
exp = new RegExp("(?:^|\\s)"+token+"(?:$|\\s)"),
t= new Date;
for(var i = 0; i < 10000; i++) {
exp.exec("foo bar baz quux");
}
return new Date - t;
})();


[" bar ", " ", " "]
vs
[" bar "]

The first one is faster (and doesn't work in IE 5.0).


F'up2 cljs

PointedEarsv
.