L
lev
Attempting to use javascript's regular expression methods to match a
particular lab number and building which would then be copied to a pair
of textfields, I found that general matching characters needing a
backslash were not recoginized. The following adapted code that finds
a two-button radio selection shows my problem:
function labstat(){
for (i=1; i<3; i++){
if(document.tester.rm_mod[i-1].checked){
var lb = document.tester.elements["lab"+(i)].value;//either
214 or 215*
var bld = document.tester.bldg.value;
if(/\*/.test(lb)){ //error:Undetermined comment
// if(/*/.test(lb)){ //error:Syntax error
// if(/5/.test(lb)){ //works to match only 215*
// if(/5\*/.test(lb)){ //true for all
// if(/\d\d\d/.test(lb)){ //false for all
document.tester.room1.value = lb;
document.tester.bldg1.value = bld;
}
}
}
It appears that the escaped characters are not recognized, whichever
form of the method is used, i.e var re = /\*/; // or = new
RegExp("\*");
if(re.test(lb)){
--------
With the --.match(__) method I have the same problem.
If someone sees my mistake of could direct me toward the source of this
problem, I would grateful.
Thanks
particular lab number and building which would then be copied to a pair
of textfields, I found that general matching characters needing a
backslash were not recoginized. The following adapted code that finds
a two-button radio selection shows my problem:
function labstat(){
for (i=1; i<3; i++){
if(document.tester.rm_mod[i-1].checked){
var lb = document.tester.elements["lab"+(i)].value;//either
214 or 215*
var bld = document.tester.bldg.value;
if(/\*/.test(lb)){ //error:Undetermined comment
// if(/*/.test(lb)){ //error:Syntax error
// if(/5/.test(lb)){ //works to match only 215*
// if(/5\*/.test(lb)){ //true for all
// if(/\d\d\d/.test(lb)){ //false for all
document.tester.room1.value = lb;
document.tester.bldg1.value = bld;
}
}
}
It appears that the escaped characters are not recognized, whichever
form of the method is used, i.e var re = /\*/; // or = new
RegExp("\*");
if(re.test(lb)){
--------
With the --.match(__) method I have the same problem.
If someone sees my mistake of could direct me toward the source of this
problem, I would grateful.
Thanks