TPRegexp C++ Wrapper for the "Perl Compatible Regular Expressions" library The PCRE lib can be found at: http://www.pcre.org/ Extensive documentation about Regular expressions in Perl can be found at : http://perldoc.perl.org/perlre.html
TPRegexp() | |
TPRegexp(const TString& pat) | |
TPRegexp(const TPRegexp& p) | |
virtual | ~TPRegexp() |
static TClass* | Class() |
TString | GetModifiers() const |
TString | GetPattern() const |
virtual TClass* | IsA() const |
Int_t | Match(const TString& s, const TString& mods = "", Int_t start = 0, Int_t nMaxMatch = 10, TArrayI* pos = 0) |
Bool_t | MatchB(const TString& s, const TString& mods = "", Int_t start = 0, Int_t nMaxMatch = 10) |
TObjArray* | MatchS(const TString& s, const TString& mods = "", Int_t start = 0, Int_t nMaxMatch = 10) |
TPRegexp& | operator=(const TPRegexp& p) |
virtual void | ShowMembers(TMemberInspector& insp, char* parent) |
virtual void | Streamer(TBuffer& b) |
void | StreamerNVirtual(TBuffer& b) |
Int_t | Substitute(TString& s, const TString& replace, const TString& mods = "", Int_t start = 0, Int_t nMatchMax = 10) |
void | Compile() |
Int_t | MatchInternal(const TString& s, Int_t start, Int_t nMaxMatch, TArrayI* pos = 0) |
void | Optimize() |
UInt_t | ParseMods(const TString& mods) const |
Int_t | ReplaceSubs(const TString& s, TString& final, const TString& replacePattern, Int_t* ovec, Int_t nmatch) const |
Int_t | SubstituteInternal(TString& s, const TString& replace, Int_t start, Int_t nMaxMatch0, Bool_t doDollarSubst) |
Returns the number of expanded '$' constructs.
Perform the actual matching - protected method.
The number of matches is returned, this equals the full match + sub-pattern matches. nMaxMatch is the maximum allowed number of matches. pos contains the string indices of the matches. Its usage is shown in the routine MatchS.
Returns a TObjArray of matched substrings as TObjString's. The TObjArray is owner of the objects. The first entry is the full matched pattern, followed by the subpatterns. If a pattern was not matched, it will return an empty substring: TObjArray *subStrL = TPRegexp("(a|(z))(bc)").MatchS("abc"); for (Int_t i = 0; i < subStrL->GetLast()+1; i++) { const TString subStr = ((TObjString *)subStrL->At(i))->GetString(); cout << "\"" << subStr << "\" "; } cout << subStr << endl; produces: "abc" "a" "" "bc"
Perform pattern substitution with optional back-ref replacement - protected method.
Substitute replaces the string s by a new string in which matching patterns are replaced by the replacePattern string. The number of substitutions are returned. TString s("aap noot mies"); const Int_t nrSub = TPRegexp("(\\w*) noot (\\w*)").Substitute(s,"$2 noot $1"); cout << nrSub << " \"" << s << "\"" <<endl; produces: 2 "mies noot aap"