【发布时间】:2010-05-11 02:17:42
【问题描述】:
在我的对象中有定期调用的功能。
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);
}
在 html 不变的情况下,m 在相互调用时返回 null。比方说
parse(html);// ok
parse(html);// m is null!!!
parse(html);// ok
parse(html);// m is null!!!
// ...and so on...
在html 上是否有任何必须重置的索引或问题...我真的很困惑。为什么match 总是返回正确的结果?
【问题讨论】:
标签: javascript regex string exec