Definition at line 36 of file TPRegexp.h.
|
| TPRegexp () |
| Default ctor. More...
|
|
| TPRegexp (const TPRegexp &p) |
| Copy ctor. More...
|
|
| TPRegexp (const TString &pat) |
| Create and initialize with pat. More...
|
|
virtual | ~TPRegexp () |
| Cleanup. More...
|
|
TString | GetModifiers () const |
| Return PCRE modifier options as string. More...
|
|
TString | GetPattern () const |
|
Bool_t | IsValid () const |
| Returns true if underlying PCRE structure has been successfully generated via regexp compilation. More...
|
|
Int_t | Match (const TString &s, const TString &mods="", Int_t start=0, Int_t nMaxMatch=10, TArrayI *pos=0) |
| The number of matches is returned, this equals the full match + sub-pattern matches. More...
|
|
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) |
| Returns a TObjArray of matched substrings as TObjString's. More...
|
|
TPRegexp & | operator= (const TPRegexp &p) |
| Assignment operator. More...
|
|
Int_t | Substitute (TString &s, const TString &replace, const TString &mods="", Int_t start=0, Int_t nMatchMax=10) |
| Substitute replaces the string s by a new string in which matching patterns are replaced by the replacePattern string. More...
|
|
|
static Bool_t | GetThrowAtCompileError () |
| Get value of static flag controlling whether exception should be thrown upon an error during regular expression compilation by the PCRE engine. More...
|
|
static void | SetThrowAtCompileError (Bool_t throwp) |
| Set static flag controlling whether exception should be thrown upon an error during regular expression compilation by the PCRE engine. More...
|
|
|
void | Compile () |
| Compile the fPattern. More...
|
|
Int_t | MatchInternal (const TString &s, Int_t start, Int_t nMaxMatch, TArrayI *pos=0) const |
| Perform the actual matching - protected method. More...
|
|
void | Optimize () |
| Send the pattern through the optimizer. More...
|
|
UInt_t | ParseMods (const TString &mods) const |
| Translate Perl modifier flags into pcre flags. More...
|
|
Int_t | ReplaceSubs (const TString &s, TString &final, const TString &replacePattern, Int_t *ovec, Int_t nmatch) const |
| Returns the number of expanded '$' constructs. More...
|
|
Int_t | SubstituteInternal (TString &s, const TString &replace, Int_t start, Int_t nMaxMatch0, Bool_t doDollarSubst) const |
| Perform pattern substitution with optional back-ref replacement. More...
|
|
#include <TPRegexp.h>
◆ anonymous enum
Enumerator |
---|
kPCRE_GLOBAL | |
kPCRE_OPTIMIZE | |
kPCRE_DEBUG_MSGS | |
kPCRE_INTMASK | |
Definition at line 39 of file TPRegexp.h.
◆ TPRegexp() [1/3]
◆ TPRegexp() [2/3]
TPRegexp::TPRegexp |
( |
const TString & |
pat | ) |
|
Create and initialize with pat.
Definition at line 60 of file TPRegexp.cxx.
◆ TPRegexp() [3/3]
TPRegexp::TPRegexp |
( |
const TPRegexp & |
p | ) |
|
◆ ~TPRegexp()
◆ Compile()
void TPRegexp::Compile |
( |
| ) |
|
|
protected |
◆ GetModifiers()
TString TPRegexp::GetModifiers |
( |
| ) |
const |
◆ GetPattern()
TString TPRegexp::GetPattern |
( |
| ) |
const |
|
inline |
◆ GetThrowAtCompileError()
Bool_t TPRegexp::GetThrowAtCompileError |
( |
| ) |
|
|
static |
Get value of static flag controlling whether exception should be thrown upon an error during regular expression compilation by the PCRE engine.
Definition at line 499 of file TPRegexp.cxx.
◆ IsValid()
Bool_t TPRegexp::IsValid |
( |
| ) |
const |
Returns true if underlying PCRE structure has been successfully generated via regexp compilation.
Definition at line 490 of file TPRegexp.cxx.
◆ Match()
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. For meaning of mods see ParseMods().
Definition at line 339 of file TPRegexp.cxx.
◆ MatchB()
◆ MatchInternal()
Perform the actual matching - protected method.
Definition at line 307 of file TPRegexp.cxx.
◆ MatchS()
Returns a TObjArray of matched substrings as TObjString's.
The TObjArray is owner of the objects and must be deleted by the user. The first entry is the full matched pattern, followed by the sub-patterns. If a pattern was not matched, it will return an empty substring:
std::cout << "\"" << subStr << "\" ";
}
std::cout << subStr << std::endl;
Int_t GetLast() const
Return index of last object in array.
TObject * At(Int_t idx) const
Collectable string class.
produces: "abc" "a" "" "bc"
For meaning of mods see ParseMods().
Definition at line 370 of file TPRegexp.cxx.
◆ operator=()
◆ Optimize()
void TPRegexp::Optimize |
( |
| ) |
|
|
protected |
Send the pattern through the optimizer.
Definition at line 230 of file TPRegexp.cxx.
◆ ParseMods()
Translate Perl modifier flags into pcre flags.
The supported modStr characters are: g, i, m, o, s, x, and the special d for debug. The meaning of the letters is:
- m Treat string as multiple lines. That is, change "^" and "$" from matching the start or end of the string to matching the start or end of any line anywhere within the string.
- s Treat string as single line. That is, change "." to match any character whatsoever, even a newline, which normally it would not match. Used together, as /ms, they let the "." match any character whatsoever, while still allowing "^" and "$" to match, respectively, just after and just before newlines within the string.
- i Do case-insensitive pattern matching.
- x Extend your pattern's legibility by permitting whitespace and comments.
- p Preserve the string matched such that ${^PREMATCH}, ${^MATCH}, and ${^POSTMATCH} are available for use after matching.
- g and c Global matching, and keep the Current position after failed matching. Unlike i, m, s and x, these two flags affect the way the regex is used rather than the regex itself. See Using regular expressions in Perl in perlretut for further explanation of the g and c modifiers. For more detail see: http://perldoc.perl.org/perlre.html#Modifiers.
Definition at line 135 of file TPRegexp.cxx.
◆ ReplaceSubs()
Returns the number of expanded '$' constructs.
Definition at line 251 of file TPRegexp.cxx.
◆ SetThrowAtCompileError()
void TPRegexp::SetThrowAtCompileError |
( |
Bool_t |
throwp | ) |
|
|
static |
Set static flag controlling whether exception should be thrown upon an error during regular expression compilation by the PCRE engine.
Definition at line 508 of file TPRegexp.cxx.
◆ Substitute()
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.
const Int_t nrSub =
TPRegexp(
"(\\w*) noot (\\w*)").Substitute(
s,
"$2 noot $1");
std::cout << nrSub <<
" \"" <<
s <<
"\"" <<std::endl;
static constexpr double s
produces: 2 "mies noot aap"
For meaning of mods see ParseMods().
Definition at line 472 of file TPRegexp.cxx.
◆ SubstituteInternal()
Perform pattern substitution with optional back-ref replacement.
Definition at line 396 of file TPRegexp.cxx.
◆ fgThrowAtCompileError
◆ fPattern
◆ fPCREOpts
◆ fPriv
PCREPriv_t* TPRegexp::fPriv |
|
protected |
[legend]