谁用过PCRE

happy_luo 2010-07-28 11:42:26
在使用pcre-8.02匹配html网页时,老是报PCRE_ERROR_MATCHLIMIT错,各种编译参数都调整过了,还没有找到原因,不知哪位遇到过这种情况
...全文
201 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianhenre 2010-11-10
  • 打赏
  • 举报
回复
happy_luo
我推测问题最大的可能是你写的正则表达式不太精准,默认的100000000次比较已经够用了。
可以检查一下你的正则表达式,是否有问题。
tianhenre 2010-11-09
  • 打赏
  • 举报
回复
happy_luo
我找到了解决方法,请看:

42. It is now possible to set a limit on the number of times the match()
function is called in a call to pcre_exec(). This facility makes it possible to
limit the amount of recursion and backtracking, though not in a directly
obvious way, because the match() function is used in a number of different
circumstances. The count starts from zero for each position in the subject
string (for non-anchored patterns). The default limit is, for compatibility, a
large number, namely 10 000 000. You can change this in two ways:

(a) When configuring PCRE before making, you can use --with-match-limit=n
to set a default value for the compiled library.

(b) For each call to pcre_exec(), you can pass a pcre_extra block in which
a different value is set. See 45 below.

If the limit is exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT

我用的版本是8.10
我的做法是
直接 在config.h 修改 a步骤的方法
#ifndef MATCH_LIMIT
#define MATCH_LIMIT 100000000 //10000000
#endif

测试成功!

b步骤的方法却没成功

你试试看,看行不行解决这个问题。
tianhenre 2010-11-09
  • 打赏
  • 举报
回复
我也遇到了这个问题,会不会是pcre对pattern有匹配次数的限制。。
正在发愁中。。。
steptodream 2010-07-28
  • 打赏
  • 举报
回复
多google一下 我也不知道

23,120

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧