Nathan Sokalski
2008-06-11 18:47:58 UTC
I have the following script that I am using to test some JavaScript RegExp
code:
function RE()
{
var testing1=new RegExp("[.]*");
var testing2=new RegExp("[.]{0,}");
var testing3=new RegExp("[.]+");
var testing4=new RegExp("[.]{1,}");
window.alert(testing1.test("ab")+"\n"+testing2.test("ab")+"\n"+testing3.test("ab")+"\n"+testing4.test("ab"));}When this script is run, the window.alert contains the following results:truetruefalsefalseThe the first two trues make since, but why are the falses false? Thequantifiers in the RegExp, if I understand correctly, say it should beallowed to have 1 or more characters (other than newlines and lineterminators), and I know that 'a' and 'b' are not newlines or lineterminators, and "ab" is more than 1 character. I am using Internet Explorer6.0. Is this a bug in IE? Am I doing something else wrong? Any help would beappreciated. Thanks.--Nathan ***@hotmail.comhttp://www.nathansokalski.com/
code:
function RE()
{
var testing1=new RegExp("[.]*");
var testing2=new RegExp("[.]{0,}");
var testing3=new RegExp("[.]+");
var testing4=new RegExp("[.]{1,}");
window.alert(testing1.test("ab")+"\n"+testing2.test("ab")+"\n"+testing3.test("ab")+"\n"+testing4.test("ab"));}When this script is run, the window.alert contains the following results:truetruefalsefalseThe the first two trues make since, but why are the falses false? Thequantifiers in the RegExp, if I understand correctly, say it should beallowed to have 1 or more characters (other than newlines and lineterminators), and I know that 'a' and 'b' are not newlines or lineterminators, and "ab" is more than 1 character. I am using Internet Explorer6.0. Is this a bug in IE? Am I doing something else wrong? Any help would beappreciated. Thanks.--Nathan ***@hotmail.comhttp://www.nathansokalski.com/