javascript string exec strange behavior
        Posted  
        
            by Michael
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Michael
        
        
        
        Published on 2010-05-11T02:17:42Z
        Indexed on 
            2010/05/11
            2:24 UTC
        
        
        Read the original article
        Hit count: 383
        
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?
© Stack Overflow or respective owner