ROOT  6.06/09
Reference Guide
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TRegexp Class Reference

Regular expression class.

'^' // start-of-line anchor
'$' // end-of-line anchor
'.' // matches any character
'[' // start a character class
']' // end a character class
'^' // negates character class if 1st character
'*' // Kleene closure (matches 0 or more)
'+' // Positive closure (1 or more)
'?' // Optional closure (0 or 1)

Note that the '|' operator (union) is not supported, nor are parentheses (grouping). Therefore "a|b" does not match "a".

Standard classes like [:alnum:], [:alpha:], etc. are not supported, only [a-zA-Z], [^ntf] and so on.

Definition at line 35 of file TRegexp.h.

Public Types

enum  EStatVal { kOK = 0, kIllegal, kNomem, kToolong }
 

Public Member Functions

 TRegexp (const char *re, Bool_t wildcard=kFALSE)
 
 TRegexp (const TString &re)
 Create a regular expression from a TString. More...
 
 TRegexp (const TRegexp &re)
 Copy ctor. More...
 
virtual ~TRegexp ()
 Destructor. More...
 
TRegexpoperator= (const TRegexp &re)
 Assignment operator. More...
 
TRegexpoperator= (const TString &re)
 Assignment operator taking a TString. More...
 
TRegexpoperator= (const char *re)
 Assignment operator taking a char* and assigning it to a regexp. More...
 
Ssiz_t Index (const TString &str, Ssiz_t *len, Ssiz_t start=0) const
 Find the first occurrence of the regexp in string and return the position, or -1 if there is no match. More...
 
EStatVal Status ()
 Check status of regexp. More...
 

Private Member Functions

void CopyPattern (const TRegexp &re)
 Copy the regular expression pattern. More...
 
void GenPattern (const char *re)
 Generate the regular expression pattern. More...
 
const char * MakeWildcard (const char *re)
 This routine transforms a wildcarding regular expression into a general regular expression used for pattern matching. More...
 

Private Attributes

Pattern_tfPattern
 
EStatVal fStat
 

Static Private Attributes

static const unsigned fgMaxpat = 2048
 

#include <TRegexp.h>

Member Enumeration Documentation

Enumerator
kOK 
kIllegal 
kNomem 
kToolong 

Definition at line 38 of file TRegexp.h.

Constructor & Destructor Documentation

TRegexp::TRegexp ( const char *  re,
Bool_t  wildcard = kFALSE 
)
TRegexp::TRegexp ( const TString re)

Create a regular expression from a TString.

Definition at line 61 of file TRegexp.cxx.

TRegexp::TRegexp ( const TRegexp re)

Copy ctor.

Definition at line 69 of file TRegexp.cxx.

TRegexp::~TRegexp ( )
virtual

Destructor.

Definition at line 77 of file TRegexp.cxx.

Member Function Documentation

void TRegexp::CopyPattern ( const TRegexp re)
private

Copy the regular expression pattern.

Definition at line 127 of file TRegexp.cxx.

Referenced by operator=(), and TRegexp().

void TRegexp::GenPattern ( const char *  re)
private

Generate the regular expression pattern.

Definition at line 117 of file TRegexp.cxx.

Referenced by operator=(), and TRegexp().

Ssiz_t TRegexp::Index ( const TString string,
Ssiz_t len,
Ssiz_t  i = 0 
) const

Find the first occurrence of the regexp in string and return the position, or -1 if there is no match.

Len is length of the matched string and i is the offset at which the matching should start.

Definition at line 208 of file TRegexp.cxx.

Referenced by TAuthenticate::CheckHost(), TSystem::CompileMacro(), TMLPAnalyzer::GatherInformations(), TString::Index(), RooStats::HistFactory::HistFactoryNavigation::SetConstant(), and TNeuron::UseBranch().

const char * TRegexp::MakeWildcard ( const char *  re)
private

This routine transforms a wildcarding regular expression into a general regular expression used for pattern matching.

When using wildcards the regular expression is assumed to be preceded by a "^" (BOL) and terminated by a "$" (EOL). Also, all "*"'s and "?"'s (closures) are assumed to be preceded by a "." (i.e. any character, except "/"'s) and all .'s are escaped (so *.ps is different from *.eps). The special treatment of "/" allows the easy matching of pathnames, e.g. "*.root" will match "aap.root", but not "pipo/aap.root".

Definition at line 144 of file TRegexp.cxx.

TRegexp & TRegexp::operator= ( const TRegexp re)

Assignment operator.

Definition at line 85 of file TRegexp.cxx.

TRegexp & TRegexp::operator= ( const TString re)

Assignment operator taking a TString.

Definition at line 107 of file TRegexp.cxx.

TRegexp & TRegexp::operator= ( const char *  re)

Assignment operator taking a char* and assigning it to a regexp.

Definition at line 97 of file TRegexp.cxx.

TRegexp::EStatVal TRegexp::Status ( )

Check status of regexp.

Definition at line 230 of file TRegexp.cxx.

Referenced by RooMapCatEntry::ok(), and RooMappedCategory::Entry::ok().

Member Data Documentation

const unsigned TRegexp::fgMaxpat = 2048
staticprivate

Definition at line 43 of file TRegexp.h.

Referenced by CopyPattern(), GenPattern(), and MakeWildcard().

Pattern_t* TRegexp::fPattern
private

Definition at line 41 of file TRegexp.h.

Referenced by CopyPattern(), GenPattern(), Index(), operator=(), and ~TRegexp().

EStatVal TRegexp::fStat
private

Definition at line 42 of file TRegexp.h.

Referenced by CopyPattern(), GenPattern(), Index(), and Status().


The documentation for this class was generated from the following files: