JPCRE2  10.31.02
C++ wrapper for PCRE2 library
jpcre2::select< Char_T, Map >::Regex Class Reference

Provides public constructors to create Regex object. More...

#include <jpcre2.hpp>

Public Member Functions

 Regex ()
 Default Constructor. More...
 
 Regex (String const &re)
 Compile pattern with initialization. More...
 
 Regex (String const *re)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 Regex (String const &re, Modifier const &mod)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 Regex (String const *re, Modifier const &mod)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 Regex (String const &re, Uint po)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 Regex (String const *re, Uint po)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 Regex (String const &re, Uint po, Uint jo)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 Regex (String const *re, Uint po, Uint jo)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 Regex (Regex const &r)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
Regexoperator= (Regex const &r)
 Overloaded assignment operator. More...
 
 Regex (Regex &&r)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
Regexoperator= (Regex &&r)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 operator bool () const
 Provides boolean check for the status of the object. More...
 
bool operator! () const
 Provides boolean check for the status of the object. More...
 
Regexreset ()
 Reset all class variables to its default (initial) state including memory. More...
 
Regexclear ()
 Clear all class variables to its default (initial) state (some memory may retain for further use). More...
 
RegexresetErrors ()
 Reset regex compile related errors to zero. More...
 
RegexresetCharacterTables ()
 Recreate character tables used by PCRE2. More...
 
Pcre2Code const * getPcre2Code () const
 Get Pcre2 raw compiled code pointer. More...
 
String getPattern () const
 Get pattern string. More...
 
String const * getPatternPointer () const
 Get pointer to pattern string. More...
 
std::string getModifier () const
 Calculate modifier string from PCRE2 and JPCRE2 options and return it. More...
 
Uint getPcre2Option () const
 Get PCRE2 option. More...
 
Uint getJpcre2Option () const
 Get JPCRE2 option. More...
 
int getErrorNumber () const
 Returns the last error number. More...
 
int getErrorOffset () const
 Returns the last error offset. More...
 
String getErrorMessage () const
 Returns the last error message. More...
 
Uint getNewLine ()
 Get new line convention from compiled code. More...
 
ModifierTable const * getModifierTable ()
 Get the modifier table that is set,. More...
 
RegexsetNewLine (Uint value)
 Set new line convention. More...
 
RegexsetPattern (String const &re)
 Set the pattern string to compile. More...
 
RegexsetPattern (String const *re)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
RegexsetModifier (Modifier const &x)
 set the modifier (resets all JPCRE2 and PCRE2 options) by calling Regex::changeModifier(). More...
 
RegexsetModifierTable (ModifierTable const *mdt)
 Set a custom modifier table to be used. More...
 
RegexsetJpcre2Option (Uint x)
 Set JPCRE2 option for compile (overwrites existing option) More...
 
RegexsetPcre2Option (Uint x)
 Set PCRE2 option for compile (overwrites existing option) More...
 
RegexchangeModifier (Modifier const &mod, bool x)
 Parse modifier and add/remove equivalent PCRE2 and JPCRE2 options. More...
 
RegexchangeJpcre2Option (Uint opt, bool x)
 Add or remove a JPCRE2 option. More...
 
RegexchangePcre2Option (Uint opt, bool x)
 Add or remove a PCRE2 option. More...
 
RegexaddModifier (Modifier const &mod)
 Parse modifier string and add equivalent PCRE2 and JPCRE2 options. More...
 
RegexaddJpcre2Option (Uint x)
 Add option to existing JPCRE2 options for compile. More...
 
RegexaddPcre2Option (Uint x)
 Add option to existing PCRE2 options for compile. More...
 
void compile (void)
 Compile pattern using info from class variables. More...
 
void compile (String const &re, Uint po, Uint jo)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
void compile (String const *re, Uint po, Uint jo)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void compile (String const &re, Uint po)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void compile (String const *re, Uint po)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void compile (String const &re, Modifier const &mod)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void compile (String const *re, Modifier const &mod)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void compile (String const &re)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void compile (String const *re)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
RegexMatch initMatch ()
 Returns a default constructed RegexMatch object by value. More...
 
RegexMatch getMatchObject ()
 Synonym for initMatch() More...
 
SIZE_T match (String const &s, Modifier const &mod, PCRE2_SIZE start_offset=0)
 Perform regex match and return match count using a temporary match object. More...
 
SIZE_T match (String const *s, Modifier const &mod, PCRE2_SIZE start_offset=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
SIZE_T match (String const &s, PCRE2_SIZE start_offset=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
SIZE_T match (String const *s, PCRE2_SIZE start_offset=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
RegexReplace initReplace ()
 Returns a default constructed RegexReplace object by value. More...
 
RegexReplace getReplaceObject ()
 Synonym for initReplace() More...
 
String replace (String const &mains, String const &repl, Modifier const &mod="", SIZE_T *counter=0)
 Perform regex replace and return the replaced string using a temporary replace object. More...
 
String replace (String *mains, String const &repl, Modifier const &mod="", SIZE_T *counter=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
String replace (String const &mains, String const *repl, Modifier const &mod="", SIZE_T *counter=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
String replace (String *mains, String const *repl, Modifier const &mod="", SIZE_T *counter=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
SIZE_T preplace (String *mains, String const &repl, Modifier const &mod="")
 Perl compatible replace method. More...
 
SIZE_T preplace (String *mains, String const *repl, Modifier const &mod="")
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Perl compatible replace method. More...
 
SIZE_T preplace (String const &mains, String const &repl, Modifier const &mod="")
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Perl compatible replace method. More...
 
SIZE_T preplace (String const &mains, String const *repl, Modifier const &mod="")
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Perl compatible replace method. More...
 

Detailed Description

template<typename Char_T, template< typename... > class Map = std::map>
class jpcre2::select< Char_T, Map >::Regex

Provides public constructors to create Regex object.

Each regex pattern needs an object of this class and each pattern needs to be compiled. Pattern compilation can be done using one of its' overloaded constructors or the Regex::compile() member function.

Examples:

jp::Regex re; //does not perform a compile
re.compile("pattern", "modifier");
jp::Regex re2("pattern", "modifier"); //performs a compile

Constructor & Destructor Documentation

◆ Regex() [1/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( )
inline

Default Constructor.

Initializes all class variables to defaults. Does not perform any pattern compilation.

◆ Regex() [2/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( String const &  re)
inline

Compile pattern with initialization.

Parameters
rePattern string

◆ Regex() [3/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( String const *  re)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePointer to pattern string. A null pointer will unset the pattern and perform a compile with empty pattern.

◆ Regex() [4/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( String const &  re,
Modifier const &  mod 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePattern string .
modModifier string.

◆ Regex() [5/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( String const *  re,
Modifier const &  mod 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePointer to pattern string. A null pointer will unset the pattern and perform a compile with empty pattern.
modModifier string.

◆ Regex() [6/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( String const &  re,
Uint  po 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePattern string .
poPCRE2 option value

◆ Regex() [7/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( String const *  re,
Uint  po 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePointer to pattern string. A null pointer will unset the pattern and perform a compile with empty pattern.
poPCRE2 option value

◆ Regex() [8/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( String const &  re,
Uint  po,
Uint  jo 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePattern string .
poPCRE2 option value
joJPCRE2 option value

◆ Regex() [9/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( String const *  re,
Uint  po,
Uint  jo 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePointer to pattern string. A null pointer will unset the pattern and perform a compile with empty pattern.
poPCRE2 option value
joJPCRE2 option value

◆ Regex() [10/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( Regex const &  r)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Copy constructor. A separate and new compile is performed from the copied options.

Parameters
rConstant Regex object reference.

◆ Regex() [11/11]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::Regex ( Regex &&  r)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Move constructor. This constructor steals resources from the argument. It leaves the argument in a valid but indeterminate sate. The indeterminate state can be returned to normal by calling reset() on that object.

Parameters
rrvalue reference to a Regex object.

Member Function Documentation

◆ addJpcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::addJpcre2Option ( Uint  x)
inline

Add option to existing JPCRE2 options for compile.

Parameters
xOption value
Returns
Reference to the calling Regex object
See also
RegexMatch::addJpcre2Option()
RegexReplace::addJpcre2Option()

◆ addModifier()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::addModifier ( Modifier const &  mod)
inline

Parse modifier string and add equivalent PCRE2 and JPCRE2 options.

This is just a wrapper of the original function Regex::changeModifier() provided for convenience.

Parameters
modModifier string.
Returns
Reference to the calling Regex object
See also
RegexMatch::addModifier()
RegexReplace::addModifier()

◆ addPcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::addPcre2Option ( Uint  x)
inline

Add option to existing PCRE2 options for compile.

Parameters
xOption value
Returns
Reference to the calling Regex object
See also
RegexMatch::addPcre2Option()
RegexReplace::addPcre2Option()

◆ changeJpcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::changeJpcre2Option ( Uint  opt,
bool  x 
)
inline

Add or remove a JPCRE2 option.

Parameters
optJPCRE2 option value
xAdd the option if it's true, remove otherwise.
Returns
Reference to the calling Regex object
See also
RegexMatch::changeJpcre2Option()
RegexReplace::changeJpcre2Option()

◆ changeModifier()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::changeModifier ( Modifier const &  mod,
bool  x 
)
inline

Parse modifier and add/remove equivalent PCRE2 and JPCRE2 options.

This function does not initialize or re-initialize options. If you want to set options from scratch, initialize them to 0 before calling this function.

If invalid modifier is detected, then the error number for the Regex object will be jpcre2::ERROR::INVALID_MODIFIER and error offset will be the modifier character. You can get the message with Regex::getErrorMessage() function.

Parameters
modModifier string.
xWhether to add or remove option
Returns
Reference to the calling Regex object
See also
RegexMatch::changeModifier()
RegexReplace::changeModifier()

References jpcre2::ModifierTable::toCompileOption().

+ Here is the call graph for this function:

◆ changePcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::changePcre2Option ( Uint  opt,
bool  x 
)
inline

Add or remove a PCRE2 option.

Parameters
optPCRE2 option value
xAdd the option if it's true, remove otherwise.
Returns
Reference to the calling Regex object
See also
RegexMatch::changePcre2Option()
RegexReplace::changePcre2Option()

◆ clear()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::clear ( )
inline

Clear all class variables to its default (initial) state (some memory may retain for further use).

Returns
Reference to the calling Regex object.

◆ compile() [1/9]

template<typename Char_T , template< typename... > class Map>
void jpcre2::select< Char_T, Map >::Regex::compile ( void  )

Compile pattern using info from class variables.

See also
Regex::compile(String const &re, Uint po, Uint jo)
Regex::compile(String const &re, Uint po)
Regex::compile(String const &re, Modifier mod)
Regex::compile(String const &re)

References jpcre2::JIT_COMPILE.

◆ compile() [2/9]

template<typename Char_T, template< typename... > class Map = std::map>
void jpcre2::select< Char_T, Map >::Regex::compile ( String const &  re,
Uint  po,
Uint  jo 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Set the specified parameters, then compile the pattern using information from class variables.

Parameters
rePattern string
poPCRE2 option
joJPCRE2 option

◆ compile() [3/9]

template<typename Char_T, template< typename... > class Map = std::map>
void jpcre2::select< Char_T, Map >::Regex::compile ( String const *  re,
Uint  po,
Uint  jo 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePointer to pattern string. A null pointer will unset the pattern and perform a compile with empty pattern.
poPCRE2 option
joJPCRE2 option

◆ compile() [4/9]

template<typename Char_T, template< typename... > class Map = std::map>
void jpcre2::select< Char_T, Map >::Regex::compile ( String const &  re,
Uint  po 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePattern string
poPCRE2 option

◆ compile() [5/9]

template<typename Char_T, template< typename... > class Map = std::map>
void jpcre2::select< Char_T, Map >::Regex::compile ( String const *  re,
Uint  po 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePointer to pattern string. A null pointer will unset the pattern and perform a compile with empty pattern.
poPCRE2 option

◆ compile() [6/9]

template<typename Char_T, template< typename... > class Map = std::map>
void jpcre2::select< Char_T, Map >::Regex::compile ( String const &  re,
Modifier const &  mod 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePattern string
modModifier string.

◆ compile() [7/9]

template<typename Char_T, template< typename... > class Map = std::map>
void jpcre2::select< Char_T, Map >::Regex::compile ( String const *  re,
Modifier const &  mod 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePointer to pattern string. A null pointer will unset the pattern and perform a compile with empty pattern.
modModifier string.

◆ compile() [8/9]

template<typename Char_T, template< typename... > class Map = std::map>
void jpcre2::select< Char_T, Map >::Regex::compile ( String const &  re)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePattern string .

◆ compile() [9/9]

template<typename Char_T, template< typename... > class Map = std::map>
void jpcre2::select< Char_T, Map >::Regex::compile ( String const *  re)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePointer to pattern string. A null pointer will unset the pattern and perform a compile with empty pattern.

◆ getErrorMessage()

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::Regex::getErrorMessage ( ) const
inline

Returns the last error message.

Returns
Last error message

References jpcre2::select< Char_T, Map >::getErrorMessage().

+ Here is the call graph for this function:

◆ getErrorNumber()

template<typename Char_T, template< typename... > class Map = std::map>
int jpcre2::select< Char_T, Map >::Regex::getErrorNumber ( ) const
inline

Returns the last error number.

Returns
Last error number

◆ getErrorOffset()

template<typename Char_T, template< typename... > class Map = std::map>
int jpcre2::select< Char_T, Map >::Regex::getErrorOffset ( ) const
inline

Returns the last error offset.

Returns
Last error offset

◆ getJpcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
Uint jpcre2::select< Char_T, Map >::Regex::getJpcre2Option ( ) const
inline

Get JPCRE2 option.

Returns
Compile time JPCRE2 option value
See also
RegexReplace::getJpcre2Option()
RegexMatch::getJpcre2Option()

◆ getMatchObject()

template<typename Char_T, template< typename... > class Map = std::map>
RegexMatch jpcre2::select< Char_T, Map >::Regex::getMatchObject ( )
inline

Synonym for initMatch()

Returns
RegexMatch object by value.

◆ getModifier()

template<typename Char_T, template< typename... > class Map = std::map>
std::string jpcre2::select< Char_T, Map >::Regex::getModifier ( ) const
inline

Calculate modifier string from PCRE2 and JPCRE2 options and return it.

Mixed or combined modifier.

Some modifier may include other modifiers i.e they have the same meaning of some modifiers combined together. For example, the 'n' modifier includes the 'u' modifier and together they are equivalent to PCRE2_UTF | PCRE2_UCP. When you set a modifier like this, both options get set, and when you remove the 'n' modifier (with Regex::changeModifier()), both will get removed.

Template Parameters
Char_TCharacter type
Returns
Calculated modifier string (std::string)
See also
RegexMatch::getModifier()
RegexReplace::getModifier()

References jpcre2::ModifierTable::fromCompileOption().

+ Here is the call graph for this function:

◆ getModifierTable()

template<typename Char_T, template< typename... > class Map = std::map>
ModifierTable const* jpcre2::select< Char_T, Map >::Regex::getModifierTable ( )
inline

Get the modifier table that is set,.

Returns
constant ModifierTable pointer.

◆ getNewLine()

template<typename Char_T, template< typename... > class Map = std::map>
Uint jpcre2::select< Char_T, Map >::Regex::getNewLine ( )
inline

Get new line convention from compiled code.

Returns
New line option value or 0.
PCRE2_NEWLINE_CR Carriage return only
PCRE2_NEWLINE_LF Linefeed only
PCRE2_NEWLINE_CRLF CR followed by LF only
PCRE2_NEWLINE_ANYCRLF Any of the above
PCRE2_NEWLINE_ANY Any Unicode newline sequence

◆ getPattern()

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::Regex::getPattern ( ) const
inline

Get pattern string.

Returns
pattern string of type jpcre2::select::String

◆ getPatternPointer()

template<typename Char_T, template< typename... > class Map = std::map>
String const* jpcre2::select< Char_T, Map >::Regex::getPatternPointer ( ) const
inline

Get pointer to pattern string.

Returns
Pointer to constant pattern string

◆ getPcre2Code()

template<typename Char_T, template< typename... > class Map = std::map>
Pcre2Code const* jpcre2::select< Char_T, Map >::Regex::getPcre2Code ( ) const
inline

Get Pcre2 raw compiled code pointer.

Returns
pointer to constant pcre2_code or null.

◆ getPcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
Uint jpcre2::select< Char_T, Map >::Regex::getPcre2Option ( ) const
inline

Get PCRE2 option.

Returns
Compile time PCRE2 option value
See also
RegexReplace::getPcre2Option()
RegexMatch::getPcre2Option()

◆ getReplaceObject()

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace jpcre2::select< Char_T, Map >::Regex::getReplaceObject ( )
inline

Synonym for initReplace()

Returns
RegexReplace object.

◆ initMatch()

template<typename Char_T, template< typename... > class Map = std::map>
RegexMatch jpcre2::select< Char_T, Map >::Regex::initMatch ( )
inline

Returns a default constructed RegexMatch object by value.

This object is initialized with the same modifier table as this Regex object.

Returns
RegexMatch object.

◆ initReplace()

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace jpcre2::select< Char_T, Map >::Regex::initReplace ( )
inline

Returns a default constructed RegexReplace object by value.

This object is initialized with the same modifier table as this Regex object.

Returns
RegexReplace object.

◆ match() [1/4]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::Regex::match ( String const &  s,
Modifier const &  mod,
PCRE2_SIZE  start_offset = 0 
)
inline

Perform regex match and return match count using a temporary match object.

This temporary match object will get available options from this Regex object, that includes modifier table.

Parameters
sSubject string .
modModifier string.
start_offsetOffset from where matching will start in the subject string.
Returns
Match count
See also
RegexMatch::match()

◆ match() [2/4]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::Regex::match ( String const *  s,
Modifier const &  mod,
PCRE2_SIZE  start_offset = 0 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Parameters
sPointer to subject string. A null pointer will unset the subject and perform a match with empty subject.
modModifier string.
start_offsetOffset from where matching will start in the subject string.
Returns
Match count

◆ match() [3/4]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::Regex::match ( String const &  s,
PCRE2_SIZE  start_offset = 0 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Parameters
sSubject string .
start_offsetOffset from where matching will start in the subject string.
Returns
Match count
See also
RegexMatch::match()

◆ match() [4/4]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::Regex::match ( String const *  s,
PCRE2_SIZE  start_offset = 0 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Parameters
sPointer to subject string. A null pointer will unset the subject and perform a match with empty subject.
start_offsetOffset from where matching will start in the subject string.
Returns
Match count
See also
RegexMatch::match()

◆ operator bool()

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::Regex::operator bool ( ) const
inlineexplicit

Provides boolean check for the status of the object.

This overloaded boolean operator needs to be declared explicit to prevent implicit conversion and overloading issues.

We will only enable it if >=C++11 is being used, as the explicit keyword for a function other than constructor is not supported in older compilers.

If you are dealing with legacy code/compilers use the Double bang trick mentioned in Regex::operator!().

This helps us to check the status of the compiled regex like this:

jpcre2::select<char>::Regex re("pat", "mod");
if(re) {
std::cout<<"Compile success";
} else {
std::cout<<"Compile failed";
}
Returns
true if regex compiled successfully, false otherwise.

◆ operator!()

template<typename Char_T, template< typename... > class Map = std::map>
bool jpcre2::select< Char_T, Map >::Regex::operator! ( ) const
inline

Provides boolean check for the status of the object.

This is a safe boolean approach (no implicit conversion or overloading). We don't need the explicit keyword here and thus it's the preferable method to check for object status that will work well with older compilers. e.g:

if(!re) {
std::cout<<"Compile failed";
} else {
std::cout<<"Compiled successfully";
}

Double bang trick:

if(!!re) {
std::cout<<"Compiled successfully";
} else {
std::cout<<"Compile failed";
}
Returns
true if regex compile failed, false otherwise.

◆ operator=() [1/2]

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::operator= ( Regex const &  r)
inline

Overloaded assignment operator.

Parameters
rRegex const &
Returns
*this

◆ operator=() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::operator= ( Regex &&  r)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Overloaded move-assignment operator. This constructor steals resources from the argument. It leaves the argument in a valid but indeterminate sate. The indeterminate state can be returned to normal by calling reset() on that object.

Parameters
rRegex&&
Returns
*this

◆ preplace() [1/4]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::Regex::preplace ( String mains,
String const &  repl,
Modifier const &  mod = "" 
)
inline

Perl compatible replace method.

Modifies subject string in-place and returns replace count.

It's a shorthand method to RegexReplace::preplace().

Parameters
mainsPointer to subject string.
replReplacement string (string to replace with).
modModifier string.
Returns
replace count.

◆ preplace() [2/4]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::Regex::preplace ( String mains,
String const *  repl,
Modifier const &  mod = "" 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Perl compatible replace method.

Modifies subject string in-place and returns replace count.

It's a shorthand method to RegexReplace::preplace().

Parameters
mainsPointer to subject string.
replPointer to replacement string (string to replace with).
modModifier string.
Returns
replace count.

◆ preplace() [3/4]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::Regex::preplace ( String const &  mains,
String const &  repl,
Modifier const &  mod = "" 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Perl compatible replace method.

Returns replace count and discards subject string.

It's a shorthand method to RegexReplace::preplace().

Parameters
mainsSubject string.
replReplacement string (string to replace with).
modModifier string.
Returns
replace count.

◆ preplace() [4/4]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::Regex::preplace ( String const &  mains,
String const *  repl,
Modifier const &  mod = "" 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Perl compatible replace method.

Returns replace count and discards subject string.

It's a shorthand method to RegexReplace::preplace().

Parameters
mainsSubject string.
replPointer to replacement string (string to replace with).
modModifier string.
Returns
replace count.

References JPCRE2_ASSERT.

◆ replace() [1/4]

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::Regex::replace ( String const &  mains,
String const &  repl,
Modifier const &  mod = "",
SIZE_T counter = 0 
)
inline

Perform regex replace and return the replaced string using a temporary replace object.

This temporary replace object will get available options from this Regex object, that includes modifier table.

Parameters
mainsSubject string.
replString to replace with
modModifier string.
counterPointer to a counter to store the number of replacement done.
Returns
Resultant string after regex replace
See also
RegexReplace::replace()

◆ replace() [2/4]

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::Regex::replace ( String mains,
String const &  repl,
Modifier const &  mod = "",
SIZE_T counter = 0 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
mainsPointer to subject string
replString to replace with
modModifier string.
counterPointer to a counter to store the number of replacement done.
Returns
Resultant string after regex replace
See also
RegexReplace::replace()

◆ replace() [3/4]

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::Regex::replace ( String const &  mains,
String const *  repl,
Modifier const &  mod = "",
SIZE_T counter = 0 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Parameters
mainsSubject string
replPointer to string to replace with
modModifier string.
counterPointer to a counter to store the number of replacement done.
Returns
Resultant string after regex replace
See also
RegexReplace::replace()

◆ replace() [4/4]

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::Regex::replace ( String mains,
String const *  repl,
Modifier const &  mod = "",
SIZE_T counter = 0 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Parameters
mainsPointer to subject string
replPointer to string to replace with
modModifier string.
counterPointer to a counter to store the number of replacement done.
Returns
Resultant string after regex replace
See also
RegexReplace::replace()

◆ reset()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::reset ( )
inline

Reset all class variables to its default (initial) state including memory.

Returns
Reference to the calling Regex object.

◆ resetCharacterTables()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::resetCharacterTables ( )
inline

Recreate character tables used by PCRE2.

You should call this function after changing the locale to remake the character tables according to the new locale. These character tables are used to compile the regex and used by match and replace operation. A separate call to compile() will be required to apply the new character tables.

Returns
Reference to the calling Regex object.

◆ resetErrors()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::resetErrors ( )
inline

Reset regex compile related errors to zero.

Returns
A reference to the Regex object
See also
RegexReplace::resetErrors()
RegexMatch::resetErrors()

◆ setJpcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::setJpcre2Option ( Uint  x)
inline

Set JPCRE2 option for compile (overwrites existing option)

Parameters
xOption value
Returns
Reference to the calling Regex object.
See also
RegexMatch::setJpcre2Option()
RegexReplace::setJpcre2Option()

◆ setModifier()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::setModifier ( Modifier const &  x)
inline

set the modifier (resets all JPCRE2 and PCRE2 options) by calling Regex::changeModifier().

Re-initializes the option bits for PCRE2 and JPCRE2 options, then parses the modifier and sets equivalent PCRE2 and JPCRE2 options.

Parameters
xModifier string.
Returns
Reference to the calling Regex object.
See also
RegexMatch::setModifier()
RegexReplace::setModifier()

◆ setModifierTable()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::setModifierTable ( ModifierTable const *  mdt)
inline

Set a custom modifier table to be used.

Parameters
mdtpointer to ModifierTable object.
Returns
Reference to the calling Regex object.

◆ setNewLine()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::setNewLine ( Uint  value)
inline

Set new line convention.

Parameters
valueNew line option value.
PCRE2_NEWLINE_CR Carriage return only
PCRE2_NEWLINE_LF Linefeed only
PCRE2_NEWLINE_CRLF CR followed by LF only
PCRE2_NEWLINE_ANYCRLF Any of the above
PCRE2_NEWLINE_ANY Any Unicode newline sequence
Returns
Reference to the calling Regex object

◆ setPattern() [1/2]

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::setPattern ( String const &  re)
inline

Set the pattern string to compile.

Parameters
rePattern string
Returns
Reference to the calling Regex object.

◆ setPattern() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::setPattern ( String const *  re)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
rePattern string pointer, null pointer will unset it.
Returns
Reference to the calling Regex object.

◆ setPcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
Regex& jpcre2::select< Char_T, Map >::Regex::setPcre2Option ( Uint  x)
inline

Set PCRE2 option for compile (overwrites existing option)

Parameters
xOption value
Returns
Reference to the calling Regex object.
See also
RegexMatch::setPcre2Option()
RegexReplace::setPcre2Option()