[thelist] regex help
Tom Dell'Aringa
pixelmech at yahoo.com
Tue Sep 2 21:29:08 CDT 2003
--- Anthony Baratta <Anthony at Baratta.com> wrote:
> Here's what I would do....
>
> Split on the S, then check each ID with the one you want to remove.
> If it does not match, append to the new string - if it does match >
skip it.
When I split on the s I get:
1,2,3,4
now I can match the '3' say, but I'm having trouble removing it. This
is what I tried:
var stuRegEx = /[s]/;
var students = thisData.split(stuRegEx);
// run through, find the match and remove it
for(var t=0;t<=students.length; t++)
{
if(students[t] == studentID.substring(1,2))
{ // remove the value
students[t] = null;
}
}
students ends up being that 1,2,3,4 list (w/o the s's). That leaves
me with a null value in that array.
Now I try to rewrite the thing without the null position, adding the
s back in:
for(var q=0;q<=students.length; q++)
{
if(students[q]){
students[q] = "s" + students[q];
thisDataField.value += students[q];
}
}
I would think this works but it won't. Any ideas anyone?
Tom
=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: Premium Content Author / JavaScript / Every Friday!
http://www.maccaws.com/ :: Group Leader
[Making A Commercial Case for Adopting Web Standards]
"That's not art, that's just annoying." -- Squidward
More information about the thelist
mailing list