Now I get what you mean (should have read your first mail better...). Indeed appears like this regular expression is in a global context, thus not being created anew while you call doTest.
Would you be surprised if I told you that the behaviour in Opera 9.52 is the same as in FF? What about IE6... well, here it differs... Makes any "12b13b" illegal! You can get that same result in FF2 and Opera when you change the regex instantiation to: var illegalChars = new RegExp("[^0-9]", "g"); Now they all seem to do the same:-) My interpretation is that var illegalChars = /[^0-9]/g; sees the regex /[^0-9]/g as a non-primitive type which just gets referenced any time you call the doTest. Using the 'new RegExp' syntax you'd instead force the creation of a new object which in turn caused the expected behaviour. Well, just a wild guess... maybe you'll have to check with the developers of the javascript engine. Anyway I consider the deviating behaviour of the browsers dangerous. > > PS: as a side effect of your example, I learned about a problem I had > > with this.debug() and was able to solve it by dealing with > > qx.log.appender. I'm not sure if I missed something, but maybe the > > documentation at > > http://qooxdoo.org/documentation/0.8/debugging > > is not complete regarding this.debug(). > Are you talking about the fact that the appenders are not included > unless you reference them, or something else? Yes, I didn't find that detail on the mentioned page. I can't remember if I had to reference anything prior to using this.debug() in qx0.6.6 or qx0.7.3, I believe that was all triggered by Makefile settings these days. Nevertheless it works for now. I'm curious if someone finds out details about these regular expression objects... Bye, Stefan Derrell Lipman wrote: > On Thu, Oct 9, 2008 at 9:01 PM, Derrell Lipman > <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > > Hi Stefan. What you describe is exactly the "problem" that I don't > understand. With a regular expression literal, as with an object > literal in 'var testobj={x:2}' or an array literal in 'var > testarr=[23,42], If someplace in that method I say 'testobj.x=3;' > the next time into that method, it'll reinitialize testobj to an > object in which x has the value 2. Similarly, I would expect a new > instantiation of a regular expression on each call into the method. > It's not assigned to a static or global variable; it's a literal > assigned to a local variable. Do you see any rationale for the > regular expression retaining its state on subsequent calls to > doTest()? Shouldn't we get a brand new, just-initialized regular > expression object assigned to illegalChars on each call to doTest()? > > > Here's a minor change to the application to demonstrate what I'm talking > about. We can see that on each call, testobj.x and testarr[0] contain > the values initialized by the object and array literals, respectively, > but illegalChars.lastIndex is clearly referencing the original regular > expressing object, not a newly-instantiated one... > > /* > #require(qx.log.appender.Native) > #require(qx.log.appender.Console) > */ > > qx.Class.define("custom.Application", > { > extend : qx.application.Standalone, > members : > { > main: function() > { > this.base(arguments); > > this.doTest("123123", true); > this.doTest("12b13b", true); > this.doTest("12b13b", true); > this.doTest("12b13b", true); > this.doTest("12b13b", true); > > this.doTest("123123", false); > this.doTest("12b13b", false); > this.doTest("12b13b", false); > this.doTest("12b13b", false); > this.doTest("12b13b", false); > this.doTest("12b13b", false); > this.doTest("12b13b", false); > this.doTest("12b13b", false); > this.doTest("12b13b", false); > this.doTest("12b13b", false); > }, > > doTest : function(s, reset) > { > var illegalChars = /[^0-9]/g; > var testobj = { x : 2 }; > var testarr = [ 23, 42 ]; > var resetText = "without"; > this.debug("lastIndex=" + illegalChars.lastIndex + ", " + > "testobj.x=" + testobj.x + ", " + > "testarr[0]=" + testarr[0]); > > if (reset) > { > illegalChars.lastIndex = 0; > resetText = "with"; > } > > var isIllegal = illegalChars.test(s); > this.debug(s + " " + resetText + > " reset: " + (isIllegal ? "illegal" : "legal")); > > testobj.x = 3; > testarr[0] = 223; > } > } > }); > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > ------------------------------------------------------------------------ > > _______________________________________________ > qooxdoo-devel mailing list > qooxdoo-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel