PIP 5.6.1
Platform-Independent Primitives
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
PIRegularExpression Class Reference

Regular expression class. More...

#include <piregularexpression.h>

Classes

class  Matcher
 Match result and iterator state. More...
 

Public Types

enum  Option {
  None = 0x0 , CaseInsensitive = 0x01 , Singleline = 0x02 , Multiline ,
  InvertedGreediness , Extended = 0x10
}
 Matching options. More...
 
typedef PIFlags< OptionOptions
 Flag set of Option values.
 

Public Member Functions

 PIRegularExpression (const PIString &pattern={}, Options opt=None)
 Creates a regular expression from pattern and opt.
 
 PIRegularExpression (const PIRegularExpression &o)
 Creates a copy of another regular expression.
 
PIRegularExpressionoperator= (const PIRegularExpression &o)
 Assigns another regular expression.
 
 ~PIRegularExpression ()
 Destroys the regular expression object.
 
PIString pattern () const
 Returns the stored pattern.
 
Options options () const
 Returns the stored options.
 
void setPattern (const PIString &pattern)
 Replaces the pattern and keeps current options.
 
void setPattern (const PIString &pattern, Options opt)
 Replaces the pattern and options.
 
bool isValid () const
 Returns true when the compiled pattern is valid.
 
bool isNotValid () const
 Returns true when the pattern is invalid.
 
PIString errorString () const
 Returns the compilation error text for an invalid pattern.
 
int errorPosition () const
 Returns the error position inside the pattern.
 
int captureGroupsCount () const
 Returns the number of capture groups in the pattern.
 
PIStringList captureGroupNames () const
 Returns the names of all named capture groups.
 
PIString captureGroupName (int index) const
 Returns the capture group name by index.
 
int captureGroupIndex (const PIString &gname) const
 Returns the index of named capture group gname.
 
Matcher match (const PIString &subject, size_t offset=0) const
 Matches against an internal copy of subject.
 
Matcher match (PIString &subject, size_t offset=0) const
 Matches against subject by reference.
 
Matcher match (PIString &&subject, size_t offset=0) const
 Matches against an rvalue subject.
 
Matcher matchIterator (const PIString &subject, size_t offset=0) const
 Prepares an iterator-style matcher over an internal copy of subject.
 
Matcher matchIterator (PIString &subject, size_t offset=0) const
 Prepares an iterator-style matcher over subject.
 
Matcher matchIterator (PIString &&subject, size_t offset=0) const
 Prepares an iterator-style matcher over an rvalue subject.
 

Static Public Member Functions

static PIRegularExpression fromGlob (const PIString &pattern, Options opt=None)
 Builds a regular expression from a glob pattern.
 
static PIRegularExpression fromPOSIX (const PIString &pattern, Options opt=None)
 Builds a regular expression from a POSIX pattern.
 

Detailed Description

Regular expression class.

Member Enumeration Documentation

◆ Option

Matching options.

Enumerator
None 

No extra options

CaseInsensitive 

Ignore character case

Singleline 

Let . match a newline

Multiline 

Let ^ and $ work on line boundaries

InvertedGreediness 

Make quantifiers non-greedy by default

Extended 

Use extended pattern syntax