I have the following code that matches just fine.
var re;
re = /23-Apr-2004/gi;
alert(re.test(d ocument.all['thebody'].innerHTML));
However, when I attempt it with a variable containing the same characters it
thows the error
"Object doesn't support this property or method" on the test line below.
var months = new
Array('Jan','Fe b','Mar','Apr', 'May','Jun','Ju l','Aug','Sep', 'Oct','Nov','De c
');
var now = new Date();
var today = now.getDate() + "-" + months[now.getMonth()] + "-" +
now.getYear();
today = "/"+today+"/gi";
var re;
re = today;
alert(re.test(d ocument.all['thebody'].innerHTML));
Can anyone tell me why this isn't working and perhaps a way around it?
var re;
re = /23-Apr-2004/gi;
alert(re.test(d ocument.all['thebody'].innerHTML));
However, when I attempt it with a variable containing the same characters it
thows the error
"Object doesn't support this property or method" on the test line below.
var months = new
Array('Jan','Fe b','Mar','Apr', 'May','Jun','Ju l','Aug','Sep', 'Oct','Nov','De c
');
var now = new Date();
var today = now.getDate() + "-" + months[now.getMonth()] + "-" +
now.getYear();
today = "/"+today+"/gi";
var re;
re = today;
alert(re.test(d ocument.all['thebody'].innerHTML));
Can anyone tell me why this isn't working and perhaps a way around it?
Comment