Unfortunately, this isn't a vb page.

I don't have almost any control on anything. This was code that was given to me that should work and I've narrowed it down to one test case (dsc00001) just to get it working.
It seems like the .replace isn't working for some reason. In spite of the fact that the re.test works dropping it inside the if.
I've looked at the RegExp documentation for Javascript on devguru as well as other sites. I've looked at examples. Seems like everything is written correctly, but it is still not working. I'm simply dumbfounded. If this was in C, I'd step through the whole thing line-by-line while watching every single variable. But I don't have any tools to do that here.
Any ideas?