0.pcre_exec
原型:
#include <pcre.h>
int pcre_exec(const pcre *code, const pcre_extra *extra, const char *subject, int length, int startoffset
, int options, int *ovector, int ovecsize);
功能:匹配成功返回非负数,没有匹配返回负数
参数:
code 输入参数,用pcre_compile编译好的正则表达结构的指针
extra 输入参数,用来向pcre_exec传一些额外的数据信息的结构的指针
subject 输入参数,要被用来匹配的字符串
length 输入参数, 要被用来匹配的字符串的指针
startoffset 输入参数,用来指定subject从什么位置开始被匹配的偏移量
options 输入参数, 用来指定匹配过程中的一些选项
ovector 输出参数,用来返回匹配位置偏移量的数组,本质上是多维数组
ovecsize 输入参数, 用来返回匹配位置偏移量的数组的最大大小 ovector的最后1/3个空间,即[2n~3n-1],貌似为pcre正则匹配算法预留,不返回结果
1.pcre_compile
原型:
#include <pcre.h>
pcre *pcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, const unsigned char *tableptr);
功能:讲一个正则表达式编译成一个内部表示,在匹配多个字符串时,可以加速匹配。其同pcre_compile2功能一样只是缺少一个参数errorcodeptr。
参数:
pattern 正则表达式
option 为0,或者其他参数选项
errptr 出错信息
erroffset 出错信息
tableptr 指向一个字符数组的指针,可以设置为空NULL
2.pcre_compile2
原型:
#include <pcre.h>
pcre *pcre_compile2(const char *pattern, int options, int *errorcodeptr, const char **errptr, int *erroffset,
const unsigned char *tableptr);
功能:将一个正则表达式编译成一个内部表示,在匹配多个字符串时,可以加速匹配。其同pcre_compile功能一样只是多一个参数errorcodeptr。
参数:
pattern 正则表达式
options 为0,或者其他参数选项
errorcodeptr 存放出错码
errptr 出错消息
erroffset 出错位置
tableptr 指向一个字符数组的指针,可以设置为空NULL
3.pcre_config
原型:
#include <pcre.h>
int pcre_config(int what, void *where);
功能:查询当前PCRE版本中使用的选项信息。
参数:
what 选项名
where 存储结果的位置
4.pcre_copy_named_substring
原型:
#include <pcre.h>
int pcre_copy_named_substring(const pcre *code, const char *subject, int *ovector, int stringcount,
const char *stringname, char *buffer, int buffersize);
功能:根据名字获取捕获的字串
参数:
code 成功匹配的模式
subject 匹配的串
ovector pcre_exec()使用的偏移向量
stringcount pcre_exec()的返回值
stringname 捕获字串的名字
buffer 用来存储的缓冲区
buffersize 缓冲区大小
5.pcre_copy_substring
原型:
#include <pcre.h>
int pcre_copy_substring(const char *subject, int *ovector, int stringcount, int stringnumber, char *buffer, int buffersize);
功能:根据编号获取捕获的字串
参数:
code 成功匹配的模式
subject 匹配的串
ovector pcre_exec()使用的偏移向量
stringcount pcre_exec()的返回值
stringnumber 捕获字串编号
buffer 用来存储的缓冲区
buffersize 缓冲区大小
6.pcre_dfa_exec
原型:
#include <pcre.h>
int pcre_dfa_exec(const pcre *code, const pcre_extra *extra, const char *subject, int length, int startoffset, int options,
int *ovector, int ovecsize, int *workspace, int wscount);
功能:使用编译好的模式进行匹配,采用的是一种非传统的方法DFA,只是对匹配串扫描一次(与Perl不兼容)
参数:
code 编译好的模式
extra 指向一个pcre_extra结构体,可以为NULL
subject 需要匹配的字符串
length 匹配的字符串长度(Byte)
startoffset 匹配的开始位置
options 选项位
ovector 指向一个结果的整形数组
ovecsize 数组大小
workspace 一个工作区数组
wscount 数组大小
7.pcre_copy_substring
原型:
#include <pcre.h>
int pcre_exec(const pcre *code, const pcre_extra *extra, const char *subject, int length, int startoffset, int options,
int *ovector, int ovecsize);
功能:使用编译好的模式进行匹配,采用与Perl相似的算法,返回匹配串的偏移位置
参数:
code 编译好的模式
extra 指向一个pcre_extra结构体,可以为NULL
subject 需要匹配的字符串
length 匹配的字符串长度(Byte)
startoffset 匹配的开始位置
options 选项位
ovector 指向一个结果的整形数组
ovecsize 数组大小
8.pcre_free_substring
原型:
#include <pcre.h>
void pcre_free_substring(const char *stringptr);
功能:释放pcre_get_substring()和pcre_get_named_substring()申请的内存空间
参数:
stringptr 指向字符串的指针

最新文章

  1. android Dialog实例
  2. JS回车事件,兼容目前所有浏览器
  3. java 打包jar文件以在没有安装JDK或JRE的机子上运行
  4. 对于flat_interface与public_interface的理解
  5. 将ntfs分区转换为ext4分区
  6. C++STL库之set的用法
  7. JSONP的原理
  8. Zepto
  9. Apache配置腾讯云SSL证书指引
  10. springMVC源码分析--异常处理机制HandlerExceptionResolver执行原理(二)
  11. day 23-1 类的命名空间、组合
  12. JavaScript(JS)之Javascript对象
  13. 解决:Reading table information for completion of table and column names
  14. eclipse测试链接sql server2008 数据库
  15. PL/SQL学习笔记之游标
  16. Go parameter passing
  17. MySQL Replication Report
  18. 为什么不能用memcached存储Session
  19. JAVA入门之程序设计环境搭建
  20. 底部线条css样式

热门文章

  1. Java面试题(原创)
  2. IOS开发----生成静态库(.a)
  3. iPhone:动态获取UILabel的高度和宽度
  4. 深入理解Linux内核-内存寻址
  5. 重载tostring()方法重要性
  6. nginx check_http_send type=http 查检测不到后端TOM的存活
  7. android - 调用系统分享功能分享图片
  8. Flink papers
  9. cxf、struts、spring中web.xml过滤url问题解决方案
  10. 【教程】InstallShield使用完全教程