PCRE庫下載

來源:互聯網
上載者:User

 http://www.psyon.org/projects/pcre-win32/index.php

 

PCRE庫下載, 我在vs2008下  5.0靜態庫編譯成功

 

#include <iostream><br />#include <string.h><br />#include "pcre.h"</p><p>#pragma comment(lib,"pcre.lib")</p><p>using namespace std;</p><p>int fun_ismatch( char* src, char* pattern)<br />{<br />int ret;<br />pcre *re;<br />const char *error;<br />int erroffset;<br />int rc;<br />pcre_extra *pcre_ex;<br />do<br /> {<br />if( (re = pcre_compile( pattern, 0, &error, &erroffset, NULL)) == NULL)<br />{<br />ret = -1;<br />break;<br />}<br />pcre_ex = pcre_study(re, 0, &error);<br />if( (rc = pcre_exec( re, pcre_ex, src, strlen(src), 0, 0, NULL, 0)) < 0)<br />{<br />ret = -1;<br />break;<br />}<br />ret = rc;<br /> }while(0);</p><p> free(re);<br /> return ret;<br />} </p><p>int main ()<br />{<br />char *src="111 <title>Hello World</title> 222";<br />char *pattern="<title>(.*)</title>";<br />int ret;</p><p>ret = fun_ismatch(src, pattern);</p><p>if(ret != -1)<br />cout<<"match"<<endl;<br />else<br />cout<<"not match"<<endl;</p><p>return 0;<br />}<br />

 

#include <stdio.h><br />#include <string.h><br />#include <pcre.h> </p><p>#define OVECCOUNT 30 /* should be a multiple of 3 */<br />#define EBUFLEN 128<br />#define BUFLEN 1024 </p><p>int main()<br />{<br /> pcre *re;<br /> const char *error;<br /> int erroffset;<br /> int ovector[OVECCOUNT];<br /> int rc, i;</p><p> char src [] = "111 <title>Hello World</title> 222";<br /> char pattern [] = "<title>(.*)</title>";</p><p> printf("String : %s/n", src);<br /> printf("Pattern: /"%s/"/n", pattern);</p><p> re = pcre_compile(pattern, 0, &error, &erroffset, NULL);<br /> if (re == NULL) {<br /> printf("PCRE compilation failed at offset %d: %s/n", erroffset, error);<br /> return 1;<br /> }</p><p> rc = pcre_exec(re, NULL, src, strlen(src), 0, 0, ovector, OVECCOUNT);<br /> if (rc < 0) {<br /> if (rc == PCRE_ERROR_NOMATCH) printf("Sorry, no match .../n");<br /> else printf("Matching error %d/n", rc);<br /> free(re);<br /> return 1;<br /> }</p><p> printf("/nOK, has matched .../n/n");</p><p> for (i = 0; i < rc; i++) {<br /> char *substring_start = src + ovector[2*i];<br /> int substring_length = ovector[2*i+1] - ovector[2*i];<br /> printf("%2d: %.*s/n", i, substring_length, substring_start);<br /> }</p><p> free(re);<br /> return 0;<br />}<br />

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.