JPCRE2  10.31.04
C++ wrapper for PCRE2 library
test0.cpp File Reference
#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")
.setModifier("g")
.setNumberedSubstringVector(&vec_num8)
.match();
std::cout<<"\nFirst match: " + vec_num8[0][0];
jpc::Regex rec_2("[\\S]+");
rm.setRegexObject(&rec_2)
.setSubject("I am subject")
.setNumberedSubstringVector(&vec_num8)
.match();
std::cout<<"\nFirst match: " + vec_num8[0][0];
std::cout<<"\nReplace: " +
rr.setSubject("I am a subject with digits 3343242 4433243 443244")
.setReplaceWith("@")
.setModifier("g")
.replace();
std::cout<<"\nReplace2: " +
rr.setSubject("I am a subject with digits 3343242 4433243 443244")
.setReplaceWith("@")
.setModifier("g")
.setRegexObject(&rec_2)
.replace();
return 0;
}
Author
Md Jahidul Hamid
jpcre2::select::RegexMatch::setMatchEndOffsetVector
virtual RegexMatch & setMatchEndOffsetVector(VecOff *v)
Set the pointer to a vector to store the offsets where matches end in the subject.
Definition: jpcre2.hpp:1752
jpcre2::select::RegexMatch::setSubject
virtual RegexMatch & setSubject(String const &s)
Set the subject string for match.
Definition: jpcre2.hpp:1762
jpcre2::select::RegexMatch::setRegexObject
virtual RegexMatch & setRegexObject(Regex const *r)
Set the associated regex object.
Definition: jpcre2.hpp:1699
jpcre2::select::Regex::setPattern
Regex & setPattern(String const &re)
Set the pattern string to compile.
Definition: jpcre2.hpp:3999
jpcre2::select::RegexMatch::setModifier
virtual RegexMatch & setModifier(Modifier const &s)
Set the modifier (resets all JPCRE2 and PCRE2 options) by calling RegexMatch::changeModifier().
Definition: jpcre2.hpp:1790
jpcre2::select::VecNum
std::vector< NumSub > VecNum
Vector of matches with numbered substrings.
Definition: jpcre2.hpp:1279
jpcre2::select::RegexReplace
Provides public constructors to create RegexReplace objects.
Definition: jpcre2.hpp:2890
jpcre2.hpp
Main header file for JPCRE2 library to be included by programs that uses its functionalities....
jpcre2::VecOff
std::vector< SIZE_T > VecOff
vector of size_t.
Definition: jpcre2.hpp:132
jpcre2::select::RegexMatch::match
virtual SIZE_T match(void)
Perform match operation using info from class variables and return the match count and store the resu...
Definition: jpcre2.hpp:4772
jpcre2::select::Regex
Provides public constructors to create Regex object.
Definition: jpcre2.hpp:3550
jpcre2::select::Regex::compile
void compile(void)
Compile pattern using info from class variables.
Definition: jpcre2.hpp:4422
jpcre2::select::RegexMatch::setNumberedSubstringVector
virtual RegexMatch & setNumberedSubstringVector(VecNum *v)
Set a pointer to the numbered substring vector.
Definition: jpcre2.hpp:1710
jpcre2::select
struct to select the types.
Definition: jpcre2.hpp:1238
jpcre2::select::RegexMatch
Provides public constructors to create RegexMatch objects.
Definition: jpcre2.hpp:1375