Http://www.psyon.org/projects/pcre-win32/index.php
Download the PCRE Library. I have compiled the 5.0 static library in vs2008
# 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 R Et; </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/* shocould 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 "); </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/>