最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

pcre函數(shù)詳細(xì)解析

 更新時間:2013年09月23日 08:56:04   作者:  
PCRE提供了19個接口函數(shù),為了簡單介紹,使用PCRE內(nèi)帶的測試程序(pcretest.c)示例用法

PCRE是一個NFA正則引擎,不然不能提供完全與Perl一致的正則語法功能。但它同時也實現(xiàn)了DFA,只是滿足數(shù)學(xué)意義上的正則。

1. pcre_compile

原型:
#include <pcre.h>
pcre *pcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, const unsigned char *tableptr);

功能:將一個正則表達(dá)式編譯成一個內(nèi)部表示,在匹配多個字符串時,可以加速匹配。其同pcre_compile2功能一樣只是缺少一個參數(shù)errorcodeptr。

參數(shù):
pattern    正則表達(dá)式
options     為0,或者其他參數(shù)選項
errptr出錯消息
erroffset  出錯位置
tableptr   指向一個字符數(shù)組的指針,可以設(shè)置為空NULL

示例:

復(fù)制代碼 代碼如下:

L1720     re = pcre_compile((char *)p, options, &error, &erroroffset, tables);

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);

功能:將一個正則表達(dá)式編譯成一個內(nèi)部表示,在匹配多個字符串時,可以加速匹配。其同pcre_compile功能一樣只是多一個參數(shù)errorcodeptr。

參數(shù):
pattern    正則表達(dá)式
options     為0,或者其他參數(shù)選項
errorcodeptr    存放出錯碼
errptr出錯消息
erroffset  出錯位置
tableptr   指向一個字符數(shù)組的指針,可以設(shè)置為空NULL

3. pcre_config

原型:
#include <pcre.h>
int pcre_config(int what, void *where);

功能:查詢當(dāng)前PCRE版本中使用的選項信息。

參數(shù):
what  選項名
where存儲結(jié)果的位置

示例:

Line1312 (void)pcre_config(PCRE_CONFIG_POSIX_MALLOC_THRESHOLD, &rc);

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);

功能:根據(jù)名字獲取捕獲的字串。

參數(shù):
code成功匹配的模式
subject 匹配的串
ovectorpcre_exec() 使用的偏移向量
stringcount   pcre_exec()的返回值
stringname捕獲字串的名字
buffer   用來存儲的緩沖區(qū)
buffersize     緩沖區(qū)大小

示例:

復(fù)制代碼 代碼如下:

Line2730 int rc = pcre_copy_named_substring(re, (char *)bptr, use_offsets,

count, (char *)copynamesptr, copybuffer, sizeof(copybuffer));


5. pcre_copy_substring

原型:
#include <pcre.h>
int pcre_copy_substring(const char *subject, int *ovector, int stringcount, int stringnumber, char *buffer, int buffersize);

功能:根據(jù)編號獲取捕獲的字串。

參數(shù):
code成功匹配的模式
subject 匹配的串
ovectorpcre_exec() 使用的偏移向量
stringcount   pcre_exec()的返回值
stringnumber   捕獲字串編號
buffer   用來存儲的緩沖區(qū)
buffersize     緩沖區(qū)大小

示例:

復(fù)制代碼 代碼如下:

Line2730 int rc = pcre_copy_substring((char *)bptr, use_offsets, count,

i, copybuffer, sizeof(copybuffer));


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);

功能:使用編譯好的模式進(jìn)行匹配,采用的是一種非傳統(tǒng)的方法DFA,只是對匹配串掃描一次(與Perl不兼容)。

參數(shù):
code     編譯好的模式
extra  指向一個pcre_extra結(jié)構(gòu)體,可以為NULL
subject    需要匹配的字符串
length匹配的字符串長度(Byte)
startoffset 匹配的開始位置
options     選項位
ovector    指向一個結(jié)果的整型數(shù)組
ovecsize   數(shù)組大小
workspace 一個工作區(qū)數(shù)組
wscount   數(shù)組大小

示例:

復(fù)制代碼 代碼如下:

Line2730 count = pcre_dfa_exec(re, extra, (char *)bptr, len, start_offset,

options | g_notempty, use_offsets, use_size_offsets, workspace,

sizeof(workspace)/sizeof(int));


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);

功能:使用編譯好的模式進(jìn)行匹配,采用與Perl相似的算法,返回匹配串的偏移位置。。

參數(shù):
code     編譯好的模式
extra  指向一個pcre_extra結(jié)構(gòu)體,可以為NULL
subject    需要匹配的字符串
length匹配的字符串長度(Byte)
startoffset 匹配的開始位置
options     選項位
ovector    指向一個結(jié)果的整型數(shù)組
ovecsize   數(shù)組大小

8. pcre_free_substring

原型:
#include <pcre.h>
void pcre_free_substring(const char *stringptr);

功能:釋放pcre_get_substring()和pcre_get_named_substring()申請的內(nèi)存空間。

參數(shù):
stringptr     指向字符串的指針

示例:

復(fù)制代碼 代碼如下:

Line2730 const char *substring;

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

i, &substring);

……

pcre_free_substring(substring);


9. pcre_free_substring_list

原型:
#include <pcre.h>
void pcre_free_substring_list(const char **stringptr);

功能:釋放由pcre_get_substring_list申請的內(nèi)存空間。

參數(shù):
stringptr     指向字符串?dāng)?shù)組的指針

示例:

復(fù)制代碼 代碼如下:

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);

功能:返回編譯出來的模式的信息。

參數(shù):
code   編譯好的模式
extra  pcre_study()的返回值,或者NULL
what  什么信息
where存儲位置

示例:

復(fù)制代碼 代碼如下:

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);

功能:根據(jù)編號獲取捕獲的字串。

參數(shù):
code成功匹配的模式
subject 匹配的串
ovectorpcre_exec() 使用的偏移向量
stringcount   pcre_exec()的返回值
stringname捕獲字串的名字
stringptr     存放結(jié)果的字符串指針

示例:

復(fù)制代碼 代碼如下:

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);

功能:根據(jù)命名捕獲的名字獲取對應(yīng)的編號。

參數(shù):
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);

功能:獲取匹配的子串。

參數(shù):
subject成功匹配的串
ovectorpcre_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);

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

參數(shù):
subject成功匹配的串
ovectorpcre_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()替換掉內(nèi)建的字符表。

參數(shù):

示例:
Line2759 tables = pcre_maketables();

17. pcre_refcount

原型:
#include <pcre.h>
int pcre_refcount(pcre *code, int adjust);

功能:編譯模式的引用計數(shù)。

參數(shù):
code已編譯的模式

adjust      調(diào)整的引用計數(shù)值

18. pcre_study

原型:
#include <pcre.h>
pcre_extra *pcre_study(const pcre *code, int options, const char **errptr);

功能:對編譯的模式進(jìn)行學(xué)習(xí),提取可以加速匹配過程的信息。

參數(shù):
code      已編譯的模式
options    選項
errptr     出錯消息

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

19. pcre_version

原型:
#include <pcre.h>
char *pcre_version(void);

功能:返回PCRE的版本信息。
參數(shù):
示例:
Line1384 if (!quiet) fprintf(outfile, "PCRE version %s/n/n", pcre_version());

相關(guān)文章

  • C++的std::vector<bool>轉(zhuǎn)儲文件問題

    C++的std::vector<bool>轉(zhuǎn)儲文件問題

    這篇文章主要介紹了C++的std::vector<bool>轉(zhuǎn)儲文件問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-11-11
  • C語言實現(xiàn)數(shù)獨游戲的求解

    C語言實現(xiàn)數(shù)獨游戲的求解

    這篇文章主要為大家詳細(xì)介紹了C語言實現(xiàn)數(shù)獨游戲的求解,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-01-01
  • 可讀可執(zhí)行的C語言簡歷源文件

    可讀可執(zhí)行的C語言簡歷源文件

    這篇文章主要為大家家詳細(xì)介紹了可讀可執(zhí)行的C語言簡歷源文件,感興趣的小伙伴們可以參考一下
    2016-07-07
  • 淺析C++中的重載,隱藏和覆蓋

    淺析C++中的重載,隱藏和覆蓋

    在C++語言中,函數(shù)扮演著很重要的角色,不管面向過程設(shè)計,還是基于對象設(shè)計。本文主要為大家介紹了函數(shù)中重載、覆蓋和隱藏的相關(guān)知識,感興趣的小伙伴可以了解一下
    2022-12-12
  • sublime text3搭建配置c語言編譯環(huán)境的詳細(xì)圖解教程(小白級)

    sublime text3搭建配置c語言編譯環(huán)境的詳細(xì)圖解教程(小白級)

    這篇文章主要介紹了sublime text3搭建配置c語言編譯環(huán)境,詳細(xì)圖解,小白教程,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-01-01
  • 淺談C++ 類的實例中 內(nèi)存分配詳解

    淺談C++ 類的實例中 內(nèi)存分配詳解

    下面小編就為大家?guī)硪黄獪\談C++ 類的實例中 內(nèi)存分配詳解。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-12-12
  • OpenCV實現(xiàn)幀間差分法詳解

    OpenCV實現(xiàn)幀間差分法詳解

    這篇文章主要為大家詳細(xì)介紹了OpenCV實現(xiàn)幀間差分法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-03-03
  • 內(nèi)部排序之堆排序的實現(xiàn)詳解

    內(nèi)部排序之堆排序的實現(xiàn)詳解

    本篇文章是對堆排序的實現(xiàn)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • 淺談十進(jìn)制小數(shù)和二進(jìn)制小數(shù)之間的轉(zhuǎn)換

    淺談十進(jìn)制小數(shù)和二進(jìn)制小數(shù)之間的轉(zhuǎn)換

    下面小編就為大家?guī)硪黄獪\談十進(jìn)制小數(shù)和二進(jìn)制小數(shù)之間的轉(zhuǎn)換。小編覺得挺不錯的現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-01-01
  • C++中的運算符重載詳解

    C++中的運算符重載詳解

    大家好,本篇文章主要講的是C++中的運算符重載詳解,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下
    2022-01-01

最新評論

遂溪县| 新巴尔虎右旗| 明光市| 郓城县| 延边| 内江市| 余庆县| 唐山市| 侯马市| 余庆县| 定远县| 平顺县| 左权县| 河西区| 株洲市| 贵溪市| 屯昌县| 泰宁县| 盐津县| 天水市| 高雄市| 平定县| 汤原县| 鹤山市| 达拉特旗| 太白县| 浑源县| 宝应县| 砀山县| 洛扎县| 伊吾县| 太和县| 金秀| 浦城县| 军事| 涞源县| 黄陵县| 留坝县| 阳东县| 肥城市| 山东省|