Sword pcre庫函數學習一

來源:互聯網
上載者:User

標籤:指定   記憶體   rto   過程   釋放   pil   需要   資訊   where   

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);  功能:講一個Regex編譯成一個內部表示,在匹配多個字串時,可以加速匹配。其同pcre_compile2功能一樣只是缺少一個參數errorcodeptr。  參數:    pattern   Regex    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);  功能:將一個Regex編譯成一個內部表示,在匹配多個字串時,可以加速匹配。其同pcre_compile功能一樣只是多一個參數errorcodeptr。  參數:    pattern    Regex    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    指向字串的指標

 

Sword pcre庫函數學習一

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.