在Lua循环中使用string.match无效。

我正在尝试使用 for 循环来获取网上论坛每个帖子的作者名称、id 和内容。我尝试过以下代码,但它并不起作用。没有 for 循环,我将只得到文档中正则表达式的第一个结果。有什么建议吗?

for author_id, author_name, author_joined, author_posts, post_date, post_content in
                string.match(content,
                "<span class=\"name\"><a name=\"(%d-)\"></a><b>([^<]+).-Joined: ([^<]+).-Posts: ([^<]+).-<span class=\"postdetails\">Posted: ([^<]+).-<span class=\"postbody\">(.-)</span><span class=\"postbody\"></span>")
        do
             document:appendContent("Name: " .. author_name)
        end
end
点赞
用户1009479
用户1009479

在普通的for循环中使用,需要一个迭代器,使用string.gmatch全局匹配)而不是string.match

2014-08-25 13:36:33