介绍, man手册

txt版 http://www.pcre.org/original/pcre.txt

html版 http://www.pcre.org/original/doc/html/pcre.html

In addition to the Perl-compatible matching function, PCRE contains an alternative function that matches the same compiled patterns in a different way. In certain circumstances, the alternative function has some advantages. For a discussion of the two matching algorithms, see the pcrematching page.

pcrematching:

http://www.pcre.org/original/doc/html/pcrematching.html

摘要:

  0.  是批量处理的意思? 一个pattern处理多个subject么?

The set of strings that are matched by a regular expression can be represented as a tree structure.

  1.  Jeffrey Friedl's book "Mastering Regular Expressions"

  中文版:精通正则表达式:https://book.douban.com/subject/2154713/

  英文版PDF:https://doc.lagout.org/Others/O%27Reilly%20-%20Mastering%20Regular%20Expressions.pdf

  2, PCRE匹配分标准接口(pcre_exec(), pcre16_exec() and pcre32_exec() functions. )和非标准接口( pcre_dfa_exec(), pcre16_dfa_exec() and pcre32_dfa_exec() functions )两种。

    前者在同一个串中只能返回一个匹配结果,或者可以同时返回一个串中的多个匹配结果。

    标准接口返回的结果有可能是最长串,最短串或任意长度的串,这取决于贪婪与非贪婪的设置。

    标准接口就是NFA algorithm是深度优先查找树,同时可以有贪婪(greedy)与非贪婪(ungreedy)两种控制种类。

    非标准接口为广度优先查找树,为DFA算法( In Friedl's terminology, this is a kind of "DFA algorithm", though it is not implemented as a traditional finite state machine (it keeps multiple states active simultaneously).)subject串的扫描会一直进行到串的尾部或者没有其他需要遍历的路径。所有的已终结路径即代表了全部的匹配结果,返回的结果按照字符串长度递减。有一个开关设置第一个命中即返回,也就是最短命中串。

  3.  非标准方法的优点:

    a, 匹配多个结果,尤其是找到最长匹配。

    b, 可以对超长的subject数据进行多次分批次的匹配。

     非标准方法的缺点:

    a, 比标准方法慢。

    b, 不支持子串提取。

    c, Although atomic groups are supported, their use does not provide the performance advantage that it does for the standard algorithm.

pcrejit:

http://www.pcre.org/original/doc/html/pcrejit.html

摘要:

  JIT提供特别深度的优化. 牺牲额外的处理步骤,从而提高匹配性能。适合一次pattern编译多次match操作的应用场景。

  1. 只支持标准PCRE接口,不支持DFA匹配模式。

  2. PCRE默认不打开JIT,需要在编译的时候增加--enable-jit选项。

  3.  有硬件平台限制

  ARM v5, v7, and Thumb2Intel x86 32-bit and 64-bitMIPS 32-bitPower PC 32-bit and 64-bitSPARC 32-bit (experimental)

  4.  the pcre_jit_exec() function was not available at all before 8.32

  5.  The JIT compiler generates different optimized code for each of the three modes (normal, soft partial, hard partial). When pcre_exec() is called, the appropriate code is run if it is available. Otherwise, the pattern is matched using interpretive code.

  6.  There are some pcre_exec() options that are not supported for JIT execution. There are also some pattern items that JIT cannot handle. Details are given below. In both cases, execution automatically falls back to the interpretive code.

  7.  Once a pattern has been studied, with or without JIT, it can be used as many times as you like for matching different subject strings.

  8.   The code that is generated by the JIT compiler is architecture-specific, and is also position dependent. For those reasons it cannot be saved (in a file or database) and restored later like the bytecode and other data of a compiled pattern.

  more info: http://www.pcre.org/original/doc/html/pcreprecompile.html

  9.  有时候JIT机器码没有成功编译,但是pcre_exec()仍然正常运行,只不过fallback回了解释码。我们在高性能场景下不希望使用解释码的时候,使用API pcre_jit_exec().

Because the API described above falls back to interpreted execution when JIT is not available, it is convenient for programs that are written for general use in many environments. However, calling JIT via pcre_exec() does have a performance impact. Programs that are written for use where JIT is known to be available, and which need the best possible performance, can instead use a "fast path" API to call JIT execution directly instead of calling pcre_exec() (obviously only for patterns that have been successfully studied by JIT).

  10.  pcre_exec()会做参数合法性的检测。pcre_jit_exec()为了提高性能,不做合法性检测,如果参数不合法,结果无法预期。

API:

http://www.pcre.org/original/doc/html/pcreapi.html

摘要:

  1,

The functions pcre_compile(), pcre_compile2(), pcre_study(), and pcre_exec() are used for compiling and matching regular expressions in a Perl-compatible manner.

  2, compile a pattern

    http://www.pcre.org/original/doc/html/pcreapi.html#SEC11

  3,    studying a pattern

Studying a pattern does two things: first, a lower bound for the length of subject string that is needed to match the pattern is computed. This does not mean that there are any strings of that length that match, but it does guarantee that no shorter strings match. The value is used to avoid wasting time by trying to match strings that are shorter than the lower bound.
Studying a pattern is also useful for non-anchored patterns that do not have a single fixed starting character. A bitmap of possible starting bytes is created. This speeds up finding a position in the subject at which to start matching.

  4,   matching a pattern

However, it is possible to save compiled patterns and study data, and then use them later in different processes, possibly even on different hosts. For a discussion about this, see the pcreprecompile documentation.

对比一下PCRE2:

[development][PCRE] PCRE

trie:

https://zh.wikipedia.org/zh-hans/Trie

-------------------

黑哥的blog:http://www.cnblogs.com/zzqcn/p/3525636.html

这个讲的很好,对比PCRE、PCRE-JIT,hyperscan:https://mp.weixin.qq.com/s?__biz=MzI3NDA4ODY4MA==&mid=2653334341&idx=1&sn=bf10ca6d8ca1452723b84a62f7fc436d&chksm=f0cb5cc2c7bcd5d4f423af8d78aeb58dd6d9494c1562b1e775579321df3b9f59a951656100d0&scene=21#wechat_redirect

转载于:https://www.cnblogs.com/hugetong/p/8619196.html

[development][PCRE] old PCRE相关推荐

  1. pcre c语言,C/C++中的正则表达式库 - PCRE,PCRE++

    最近使用boost::regex正则,遇到了延时问题,更换为pcre,延时问题得到解决.这里记录一下pcre的内容. PCRE,PCRE++介绍 PCRE :(Perl Compatible Regu ...

  2. PCRE函数简介和使用示例

    PCRE是一个NFA正则引擎,不然不能提供完全与Perl一致的正则语法功能.但它同时也实现了DFA,只是满足数学意义上的正则. PCRE Windows版本库文件 下载地址:http://downlo ...

  3. pcre安装_Nginx | Nginx的介绍和安装

    Nginx 简介 Nginx 是互联网主流的高性能 http 和 反响代理 Web 服务器,Nginx 不但可以作为 Web 服务器,它还提供了静态资源服务.缓存.负载均衡 等功能. Nginx 有很 ...

  4. VisualFreeBasic的pcre/pcre2正则表达式修复

    VisualFreeBasic中使用CRegex其实就是vbscript里面的正则,性能比较弱 同时在他的文件头库里面分别有pcre两个版本的bi头文件 只是对应的库没有加进来,本人的主要目的,就是记 ...

  5. centos 7 在线安装nginx 查看gcc,pcre,zlib,openssl 等依赖是否安装

    之前整理过centos 7 离线安装nginx的步骤 在线安装相对操作就简易多了 查看安装nginx需要的依赖是否已安装 没安装yum指令在线安装即可 我使用的是centos7.6版本 安装的ngin ...

  6. 从PCRE到Hyperscan 性能对比

    Hyperscan作为高性能的正则表达式匹配库,使用者通常乐意将其与传统的正则表达式匹配库进行比较."为什么要用Hyperscan?""使用Hyperscan对我有怎样的 ...

  7. PCRE的安装及使用

    1.主页地址:http://www.pcre.org/      下载pcre-7.8.tar.bz2 2.解压缩:      tar xjpf pcre-7.8.tar.bz2 3.配置:      ...

  8. apache 2.4.12 + tomcat 7.0.61 + jk connectors 1.2.40实现tomcat负载均衡集群

    实验环境:     CentOS 5.11 final     hostname:T1.getg.com     IP地址:192.168.50.138 软件准备:     CentOS Linux ...

  9. 在Server 2003上部署IIS+PHP+MySQL配置清单

    在Server 2003上部署IIS+PHP+MySQL I.安装Windows Server 2003 将光盘放入光驱中,设置BIOS,从CDROM引导加载安装程序,等待启动: 设置注册信息,名字和 ...

最新文章

  1. poj3508(高精度模拟减法)
  2. pybind传输list
  3. android反编译的方法
  4. Java LocalDate类| ofYearDay()方法与示例
  5. Windows下重叠I/O模型
  6. 接口测试工具-Jmeter使用笔记(九:跨线程组传递变量)
  7. hibernate多对多映射关系实现
  8. 【洛谷P1169】[ZJOI2007]棋盘制作
  9. 自适应模糊PID(位置式)C语言实现
  10. http://95u.free.fr/index.php,Electronic Software Distribution Service
  11. 浅谈如何根治慢性扁桃体炎-个人经验总结
  12. 阴阳师android转ios,阴阳师手游IOS自动刷御魂?IOS切换控制教程[多图]
  13. javawebJAVAJSP酒店预订系统jsp酒店管理系统jsp民宿预订酒店jsp客房预订系统jsp宾馆客房预订系统
  14. 如何判断一个指定的位置点坐标(GPS上的经纬度)是否落在一个多边形区域内?
  15. 基于java博网即时通讯软件的设计与实现
  16. 更改计算机用户名不能上网,电脑网络用户名改了连接不上怎么办
  17. 元宵到·桃花开,情人节征文活动榜单已公布!
  18. array.includes的使用
  19. 稳压模块在输入和输出引脚之间并联一个二极管的目地
  20. 乐优商场项目day13—页面渲染

热门文章

  1. Vitalik Buterin:Casper 权益证明与分片技术最新进展
  2. EOS经济系统分析[转载]
  3. 理解Android Binder机制(3/3):Java层
  4. Android 插件框架实现思路及原理
  5. 文件不混淆_Android Studio配置反混淆
  6. 如何判断离散数组 是递增趋势_如何用切线技术判断市场趋势?
  7. Qt 2D painting Demo 的翻译
  8. sparksql dataframe变成csv保存_Spark大数据分析(三):DataFrame和SQL
  9. 2022.2.28集成电子开关电路TWH8778
  10. COGS-257-动态排名系统-树状数组+主席树