JPCRE2  10.31.02
C++ wrapper for PCRE2 library
test0.cpp File Reference

An example of handling std::string and std::wstring. More...

#include <iostream>
#include "jpcre2.hpp"
+ Include dependency graph for test0.cpp:

Detailed Description

An example of handling std::string and std::wstring.

#include <iostream>
#include "jpcre2.hpp"
int main(){
rec.setPattern("\\d+").compile();
rew.setPattern(L"\\d+").compile();
jpw::VecNum vec_num32;
jpcre2::VecOff vec_eoff;
size_t count =
rmw.setRegexObject(&rew)
.setSubject(L"123456789")
.match();
std::cout<<"\nMatch count: "<<count;
std::wcout<<"\nFirst match: "<<vec_num32[0][0];
std::cout<<"\nMatch ended at offset: "<<vec_eoff[vec_eoff.size()-1];
std::cout<<"\n--------------------------------\n";
rm.setRegexObject(&rec);
rr.setRegexObject(&rec);
jpc::VecNum vec_num8;
rm.setSubject("I am a subject with digits 3343242 4433243 443244")
.match();
std::cout<<"\nFirst match: " + vec_num8[0][0];
jpc::Regex rec_2("[\\S]+");
rm.setRegexObject(&rec_2)
.setSubject("I am subject")
.match();
std::cout<<"\nFirst match: " + vec_num8[0][0];
std::cout<<"\nReplace: " +
rr.setSubject("I am a subject with digits 3343242 4433243 443244")
.replace();
std::cout<<"\nReplace2: " +
rr.setSubject("I am a subject with digits 3343242 4433243 443244")
.setRegexObject(&rec_2)
.replace();
return 0;
}
Author
Md Jahidul Hamid