DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

C++ C Regex Library Pcrecpp

07.24.2009
| 3855 views |
  • submit to reddit
        // description of your code here

#include "pcrecpp.h"
#include<string>
#include<iostream>
using namespace std;
int main()
{
        pcrecpp::RE re("a(.+?)b(.+?)c");
        pcrecpp::RE re_item("@ITEM@");
        string s1,s2;
        int i,j;
        if(re.FullMatch("a3bccc",&s1,&s2))
        {
                cout<<"ok\trst:"<<s1<<","<<s2<<endl;
        }
        string input="my name is @ITEM@ ,your name is @ITEM@.";
        re_item.Replace("jack",&input);
        re_item.Replace("jerry",&input);
        cout<<input<<endl;
}