你好,游客 登录 注册 搜索
背景:
阅读新闻

PCRE函数详解

[日期:2014-04-05] 来源:Linux社区  作者:Linux [字体:大 中 小]

9. pcre_free_substring_list

原型:

#include <pcre.h>

void pcre_free_substring_list(const char **stringptr);

功能:释放由pcre_get_substring_list申请的内存空间。

参数:

stringptr 指向字符串数组的指针

示例:

Line2773 const char **stringlist;

int rc = pcre_get_substring_list((char *)bptr, use_offsets, count,

……

pcre_free_substring_list(stringlist);



10. pcre_fullinfo

原型:

#include <pcre.h>

int pcre_fullinfo(const pcre *code, const pcre_extra *extra, int what, void *where);

功能:返回编译出来的模式的信息。

参数:

code 编译好的模式

extra pcre_study()的返回值,或者NULL

what 什么信息

where 存储位置

示例:

Line997 if ((rc = pcre_fullinfo(re, study, option, ptr)) < 0)

fprintf(outfile, "Error %d from pcre_fullinfo(%d)/n", rc, option);

}



11. pcre_get_named_substring

原型:

#include <pcre.h>

int pcre_get_named_substring(const pcre *code, const char *subject, int *ovector, int stringcount, const char *stringname, const char **stringptr);

功能:根据编号获取捕获的字串。

参数:

code 成功匹配的模式

subject 匹配的串

ovector pcre_exec() 使用的偏移向量

stringcount pcre_exec()的返回值

stringname 捕获字串的名字

stringptr 存放结果的字符串指针

示例:

Line2759 const char *substring;

int rc = pcre_get_named_substring(re, (char *)bptr, use_offsets,

count, (char *)getnamesptr, &substring);



12. pcre_get_stringnumber

原型:

#include <pcre.h>

int pcre_get_stringnumber(const pcre *code, const char *name);

功能:根据命名捕获的名字获取对应的编号。

参数:

code 成功匹配的模式

name 捕获名字



13. pcre_get_substring

原型:

#include <pcre.h>

int pcre_get_substring(const char *subject, int *ovector, int stringcount, int stringnumber, const char **stringptr);

功能:获取匹配的子串。

参数:

subject 成功匹配的串

ovector pcre_exec() 使用的偏移向量

stringcount pcre_exec()的返回值

stringnumber 获取的字符串编号

stringptr 字符串指针



14. pcre_get_substring_list

原型:

#include <pcre.h>

int pcre_get_substring_list(const char *subject, int *ovector, int stringcount, const char ***listptr);

功能:获取匹配的所有子串。

参数:

subject 成功匹配的串

ovector pcre_exec() 使用的偏移向量

stringcount pcre_exec()的返回值

listptr 字符串列表的指针



15. pcre_info

原型:

#include <pcre.h>

int pcre_info(const pcre *code, int *optptr, int *firstcharptr);

已过时,使用pcre_fullinfo替代。



16. pcre_maketables

原型:

#include <pcre.h>

const unsigned char *pcre_maketables(void);

功能:生成一个字符表,表中每一个元素的值不大于256,可以用它传给pcre_compile()替换掉内建的字符表。

参数:

示例:

Line2759 tables = pcre_maketables();



17. pcre_refcount

原型:

#include <pcre.h>

int pcre_refcount(pcre *code, int adjust);

功能:编译模式的引用计数。

参数:

code 已编译的模式

adjust 调整的引用计数值



18. pcre_study

原型:

#include <pcre.h>

pcre_extra *pcre_study(const pcre *code, int options, const char **errptr);

功能:对编译的模式进行学习,提取可以加速匹配过程的信息。

参数:

code 已编译的模式

options 选项

errptr 出错消息

示例:

Line1797 extra = pcre_study(re, study_options, &error);



19. pcre_version

原型:

#include <pcre.h>

char *pcre_version(void);

功能:返回PCRE的版本信息。

参数:

示例:

Line1384 if (!quiet) fprintf(outfile, "PCRE version %s/n/n", pcre_version());

linux
相关资讯       PCRE  PCRE函数 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款