class TPRegexp


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


Function Members (Methods)

public:
TPRegexp()
TPRegexp(const TString& pat)
TPRegexp(const TPRegexp& p)
virtual~TPRegexp()
static TClass*Class()
virtual TClass*IsA() const
Int_tMatch(const TString& s, const TString& mods = "", Int_t offset = 0, Int_t nMatchMax = 30, TArrayI* pos = 0)
Bool_tMatchB(const TString& s, const TString& mods = "", Int_t offset = 0, Int_t nMaxMatch = 30)
TObjArray*MatchS(const TString& s, const TString& mods = "", Int_t offset = 0, Int_t nMaxMatch = 30)
TPRegexp&operator=(const TPRegexp& p)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
Int_tSubstitute(TString& s, const TString& replace, const TString& mods = "", Int_t offset = 0, Int_t nMatchMax = 30)
private:
voidCompile()
voidOptimize()
UInt_tParseMods(const TString& mods) const
Int_tReplaceSubs(const TString& s, TString& final, const TString& replacePattern, Int_t* ovec, Int_t nmatch) const

Data Members

public:
enum { kPCRE_GLOBAL
kPCRE_OPTIMIZE
kPCRE_DEBUG_MSGS
kPCRE_INTMASK
};
private:
UInt_tfPCREOpts
TStringfPattern
PCREPriv_t*fPriv

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TPRegexp()
 Default ctor.
TPRegexp(const TString &pat)
 Create and initialize with pat.
TPRegexp(const TPRegexp &p)
 Copy ctor.
~TPRegexp()
 Cleanup.
TPRegexp & operator=(const TPRegexp& p)
 Assignement operator.
UInt_t ParseMods(const TString& mods) const
 Translate Perl modifier flags into pcre flags.
void Compile()
 Compile the fPattern.
void Optimize()
 Send the pattern through the optimizer.
Int_t ReplaceSubs(const TString& s, TString& final, const TString& replacePattern, Int_t* ovec, Int_t nmatch) const
 Return the number of substitutions.
Int_t Match(const TString& s, const TString& mods = "", Int_t offset = 0, Int_t nMatchMax = 30, TArrayI* pos = 0)
 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.
TObjArray * MatchS(const TString& s, const TString& mods = "", Int_t offset = 0, Int_t nMaxMatch = 30)
 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"
Int_t Substitute(TString& s, const TString& replace, const TString& mods = "", Int_t offset = 0, Int_t nMatchMax = 30)
 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"
Bool_t MatchB(const TString& s, const TString& mods = "", Int_t offset = 0, Int_t nMaxMatch = 30)

Author: Eddy Offermann 24/06/05
Last update: root/base:$Id: TPRegexp.h 20877 2007-11-19 11:17:07Z rdm $
Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.