views:

50

answers:

1

have funciton in my object which is called regularly.

parse : function(html)
{
    var regexp = /...some pattern.../
    var match = regexp.exec(html);
    while (match != null)
    {
        ...
        match = regexp.exec(html);
    }
    ...
    var r = /...pattern.../g;
    var m = r.exec(html);
}

with unchanged html the m returns null each other call. let's say

parse(html);// ok
parse(html);// m is null!!!
parse(html);// ok
parse(html);// m is null!!!
// ...and so on...

is there any index or somrthing that has to be reset on html ... I'm really confused. Why match always returns proper result?

+2  A: 
CMS
Yea I was suspecting something like that, but how come those regex variables are not gc-ed and being reset? I believe each time I call parse() the new scope should be initialized.
Michael
@Michael, give a look to my edit...
CMS