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

Provides public constructors to create RegexReplace objects. More...

#include <jpcre2.hpp>

Public Member Functions

 RegexReplace ()
 Default constructor. More...
 
 RegexReplace (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...
 
 RegexReplace (RegexReplace const &rr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
RegexReplaceoperator= (RegexReplace const &rr)
 Overloaded Copy assignment operator. More...
 
 RegexReplace (RegexReplace &&rr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
RegexReplaceoperator= (RegexReplace &&rr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
RegexReplacereset ()
 Reset all class variables to its default (initial) state including memory. More...
 
RegexReplaceclear ()
 Clear all class variables to its default (initial) state (some memory may retain for further use). More...
 
RegexReplaceresetErrors ()
 Reset replace related errors to zero. 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...
 
String getReplaceWith () const
 Get replacement string. More...
 
String const * getReplaceWithPointer () const
 Get pointer to replacement string. More...
 
String getSubject () const
 Get subject string. More...
 
String const * getSubjectPointer () const
 Get pointer to subject string. More...
 
std::string getModifier () const
 Calculate modifier string from PCRE2 and JPCRE2 options and return it. More...
 
ModifierTable const * getModifierTable ()
 Get the modifier table that is set,. More...
 
PCRE2_SIZE getStartOffset () const
 Get start offset. More...
 
Uint getPcre2Option () const
 Get PCRE2 option. More...
 
Uint getJpcre2Option () const
 Get JPCRE2 option. More...
 
Regex const * getRegexObject () const
 Get a pointer to the associated Regex object. More...
 
MatchContext * getMatchContext ()
 Return pointer to the match context that was previously set with setMatchContext(). More...
 
virtual MatchData * getMatchDataBlock ()
 Get the pointer to the match data block that was set previously with setMatchData() Handling memory is the callers' responsibility. More...
 
PCRE2_SIZE getBufferSize ()
 Get the initial buffer size that is being used by internal function pcre2_substitute. More...
 
SIZE_T getLastReplaceCount ()
 Get the number of replacement in last replace operation. More...
 
RegexReplacesetReplaceCounter (SIZE_T *counter)
 Set an external counter variable to store the replacement count. More...
 
RegexReplacesetRegexObject (Regex const *r)
 Set the associated Regex object. More...
 
RegexReplacesetSubject (String const &s)
 Set the subject string for replace. More...
 
RegexReplacesetSubject (String *s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
RegexReplacesetReplaceWith (String const &s)
 Set the replacement string. More...
 
RegexReplacesetReplaceWith (String const *s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
RegexReplacesetModifier (Modifier const &s)
 Set the modifier string (resets all JPCRE2 and PCRE2 options) by calling RegexReplace::changeModifier(). More...
 
RegexReplacesetModifierTable (ModifierTable const *mdt)
 Set a custom modifier table to be used. More...
 
RegexReplacesetBufferSize (PCRE2_SIZE x)
 Set the initial buffer size to be allocated for replaced string (used by PCRE2) More...
 
RegexReplacesetStartOffset (PCRE2_SIZE start_offset)
 Set start offset. More...
 
RegexReplacesetJpcre2Option (Uint x)
 Set JPCRE2 option for replace (overwrite existing option) More...
 
RegexReplacesetPcre2Option (Uint x)
 Set PCRE2 option replace (overwrite existing option) More...
 
RegexReplacesetMatchContext (MatchContext *match_context)
 Set the match context to be used. More...
 
RegexReplacesetMatchDataBlock (MatchData *match_data)
 Set the match data block to be used. More...
 
RegexReplacechangeModifier (Modifier const &mod, bool x)
 After a call to this function PCRE2 and JPCRE2 options will be properly set. More...
 
RegexReplacechangeJpcre2Option (Uint opt, bool x)
 Parse modifier and add/remove equivalent PCRE2 and JPCRE2 options. More...
 
RegexReplacechangePcre2Option (Uint opt, bool x)
 Add or remove a PCRE2 option. More...
 
RegexReplaceaddModifier (Modifier const &mod)
 Parse modifier string and add equivalent PCRE2 and JPCRE2 options. More...
 
RegexReplaceaddJpcre2Option (Uint x)
 Add specified JPCRE2 option to existing options for replace. More...
 
RegexReplaceaddPcre2Option (Uint x)
 Add specified PCRE2 option to existing options for replace. More...
 
String replace (void)
 Perform regex replace by retrieving subject string, replacement string, modifier and other options from class variables. More...
 
SIZE_T preplace (void)
 Perl compatible replace method. More...
 
SIZE_T preplace (MatchEvaluator me)
 Perl compatible replace method with match evaluator. More...
 
String nreplace (MatchEvaluator me)
 JPCRE2 native replace function. More...
 
String replace (MatchEvaluator me)
 PCRE2 compatible replace function that takes a MatchEvaluator. More...
 

Detailed Description

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

Provides public constructors to create RegexReplace objects.

Every RegexReplace object should be associated with a Regex object. This class stores a pointer to its' associated Regex object, thus when the content of the associated Regex object is changed, there's no need to set the pointer again.

Examples:

rr.replace("subject", "me"); // returns 'subject'
re.compile("\\w+");
rr.replace(); // replaces 'subject' with 'me' i.e returns 'me'

Constructor & Destructor Documentation

◆ RegexReplace() [1/4]

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

Default constructor.

◆ RegexReplace() [2/4]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::RegexReplace::RegexReplace ( 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. ...

Creates a RegexReplace object associating a Regex object. Regex object is not modified.

Parameters
rpointer to a Regex object

◆ RegexReplace() [3/4]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::RegexReplace::RegexReplace ( RegexReplace const &  rr)
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.

Parameters
rrRegexReplace object reference

◆ RegexReplace() [4/4]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::RegexReplace::RegexReplace ( RegexReplace &&  rr)
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
rrrvalue reference to a RegexReplace object reference

Member Function Documentation

◆ addJpcre2Option()

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

Add specified JPCRE2 option to existing options for replace.

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

◆ addModifier()

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

Parse modifier string and add equivalent PCRE2 and JPCRE2 options.

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

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

◆ addPcre2Option()

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

Add specified PCRE2 option to existing options for replace.

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

◆ changeJpcre2Option()

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

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

Add or remove a JPCRE2 option

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

◆ changeModifier()

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

After a call to this function PCRE2 and JPCRE2 options will be properly set.

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 RegexReplace object will be jpcre2::ERROR::INVALID_MODIFIER and error offset will be the modifier character. You can get the message with RegexReplace::getErrorMessage() function.

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

References jpcre2::ModifierTable::toReplaceOption().

+ Here is the call graph for this function:

◆ changePcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::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 RegexReplace object
See also
RegexMatch::changePcre2Option()
Regex::changePcre2Option()

◆ clear()

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

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

Returns
Reference to the calling RegexReplace object.

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

Referenced by jpcre2::select< Char_T, Map >::RegexReplace::clear(), jpcre2::select< Char_T, Map >::RegexReplace::setReplaceWith(), and jpcre2::select< Char_T, Map >::RegexReplace::setSubject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBufferSize()

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

Get the initial buffer size that is being used by internal function pcre2_substitute.

Returns
buffer_size

◆ getErrorMessage()

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::RegexReplace::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 >::RegexReplace::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 >::RegexReplace::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 >::RegexReplace::getJpcre2Option ( ) const
inline

Get JPCRE2 option.

Returns
JPCRE2 option for replace
See also
Regex::getJpcre2Option()
RegexMatch::getJpcre2Option()

◆ getLastReplaceCount()

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

Get the number of replacement in last replace operation.

If you set an external counter with RegexReplace::setReplaceCounter(), a call to this getter method will dereference the pointer to the external counter and return the value.

Returns
Last replace count

◆ getMatchContext()

template<typename Char_T, template< typename... > class Map = std::map>
MatchContext* jpcre2::select< Char_T, Map >::RegexReplace::getMatchContext ( )
inline

Return pointer to the match context that was previously set with setMatchContext().

Handling memory is the callers' responsibility.

Returns
pointer to the match context (default: null).

◆ getMatchDataBlock()

template<typename Char_T, template< typename... > class Map = std::map>
virtual MatchData* jpcre2::select< Char_T, Map >::RegexReplace::getMatchDataBlock ( )
inlinevirtual

Get the pointer to the match data block that was set previously with setMatchData() Handling memory is the callers' responsibility.

Returns
pointer to the match data (default: null).

◆ getModifier()

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

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

Do remember that modifiers (or PCRE2 and JPCRE2 options) do not change or get initialized as long as you don't do that explicitly. Calling RegexReplace::setModifier() will re-set them.

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 RegexReplace::changeModifier()), both will get removed.

Returns
Calculated modifier string (std::string)
See also
RegexMatch::getModifier()
Regex::getModifier()

References jpcre2::ModifierTable::fromReplaceOption().

+ 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 >::RegexReplace::getModifierTable ( )
inline

Get the modifier table that is set,.

Returns
constant ModifierTable pointer.

◆ getPcre2Option()

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

Get PCRE2 option.

Returns
PCRE2 option for replace
See also
Regex::getPcre2Option()
RegexMatch::getPcre2Option()

◆ getRegexObject()

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

Get a pointer to the associated Regex object.

If no actual Regex object is associated, null is returned

Returns
A pointer to the associated constant Regex object or null

◆ getReplaceWith()

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

Get replacement string.

Returns
replacement string

◆ getReplaceWithPointer()

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

Get pointer to replacement string.

Returns
pointer to replacement string

◆ getStartOffset()

template<typename Char_T, template< typename... > class Map = std::map>
PCRE2_SIZE jpcre2::select< Char_T, Map >::RegexReplace::getStartOffset ( ) const
inline

Get start offset.

Returns
the start offset where matching starts for replace operation

◆ getSubject()

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

Get subject string.

Returns
subject string
See also
RegexMatch::getSubject()

◆ getSubjectPointer()

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

Get pointer to subject string.

Returns
Pointer to constant subject string
See also
RegexMatch::getSubjectPointer()

◆ nreplace()

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::RegexReplace::nreplace ( MatchEvaluator  me)
inline

JPCRE2 native replace function.

A different name is adopted to distinguish itself from the regular replace() function which uses pcre2_substitute() to do the replacement; contrary to that, it will provide a JPCRE2 native way of replacement operation. It takes a MatchEvaluator object which provides a callback function that is used to generate replacement string on the fly. Any replacement string set with RegexReplace::setReplaceWith() function will have no effect. The string returned by the callback function will be treated as literal and will not go through any further processing.

This function works on a copy of the MatchEvaluator, and thus makes no changes to the original. The copy is modified as below:

  1. Global replacement will set FIND_ALL for match, unset otherwise.
  2. Bad matching options such as PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT will be removed.
  3. subject, start_offset and Regex object will change according to the RegexReplace object.
  4. match context, and match data block will be changed according to the RegexReplace object.

It calls MatchEvaluator::nreplace() on the MatchEvaluator object to perform the replacement.

It always performs a new match.

Parameters
meA MatchEvaluator object.
Returns
The resultant string after replacement.
See also
MatchEvaluator::nreplace()
MatchEvaluator
MatchEvaluatorCallback

◆ operator=() [1/2]

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

Overloaded Copy assignment operator.

Parameters
rrRegexReplace object reference
Returns
A reference to the calling RegexReplace object

◆ operator=() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::operator= ( RegexReplace &&  rr)
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
rrrvalue reference to a RegexReplace object reference
Returns
A reference to the calling RegexReplace object

◆ preplace() [1/2]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::RegexReplace::preplace ( void  )
inline

Perl compatible replace method.

Modifies subject string in-place and returns replace count.

The replacement is performed with RegexReplace::replace() which uses pcre2_substitute().

Returns
replace count

◆ preplace() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::RegexReplace::preplace ( MatchEvaluator  me)
inline

Perl compatible replace method with match evaluator.

Modifies subject string in-place and returns replace count. MatchEvaluator class does not have a implementation of this replace method, thus it is not possible to re-use match data with preplace() method. Re-using match data with preplace doesn't actually make any sense, because new subject will always require new match data.

The replacement is performed with RegexReplace::replace() which uses pcre2_substitute().

Parameters
meMatchEvaluator object.
Returns
replace count

◆ replace() [1/2]

template<typename Char_T , template< typename... > class Map>
jpcre2::select< Char_T, Map >::String jpcre2::select< Char_T, Map >::RegexReplace::replace ( void  )

Perform regex replace by retrieving subject string, replacement string, modifier and other options from class variables.

In the replacement string (see RegexReplace::setReplaceWith()) $ is a special character which implies captured group.

  1. A numbered substring can be referenced with $n or ${n} where n is the group number.
  2. A named substring can be referenced with ${name}, where 'name' is the group name.
  3. A literal $ can be given as $$.
  4. Bash like features: ${<n>:-<string>} and ${<n>:+<string1>:<string2>}, where <n> is a group number or name.

All options supported by pcre2_substitute is available.

Note: This function calls pcre2_substitute() to do the replacement.

Returns
Replaced string

◆ replace() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
String jpcre2::select< Char_T, Map >::RegexReplace::replace ( MatchEvaluator  me)
inline

PCRE2 compatible replace function that takes a MatchEvaluator.

String returned by callback function is processed by pcre2_substitute, thus all PCRE2 substitute options are supported by this replace function.

It always performs a new match.

Parameters
meMatchEvaluator instance, (copied and modified according to this object).
Returns
resultant string.
See also
replace()

◆ reset()

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

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

Returns
Reference to the calling RegexReplace object.

◆ resetErrors()

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

Reset replace related errors to zero.

Returns
Reference to the calling RegexReplace object
See also
Regex::resetErrors()
RegexMatch::resetErrors()

◆ setBufferSize()

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::setBufferSize ( PCRE2_SIZE  x)
inline

Set the initial buffer size to be allocated for replaced string (used by PCRE2)

Parameters
xBuffer size
Returns
Reference to the calling RegexReplace object

◆ setJpcre2Option()

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

Set JPCRE2 option for replace (overwrite existing option)

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

◆ setMatchContext()

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::setMatchContext ( MatchContext *  match_context)
inline

Set the match context to be used.

Native PCRE2 API may be used to create match context. The memory of the match context is not handled by RegexReplace object and not freed. User will be responsible for freeing memory.

Parameters
match_contextPointer to match context.
Returns
Reference to the calling RegexReplace object.

◆ setMatchDataBlock()

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::setMatchDataBlock ( MatchData *  match_data)
inline

Set the match data block to be used.

Native PCRE2 API may be used to create match data block. The memory of the match data is not handled by RegexReplace object and not freed. User will be responsible for creating/freeing memory.

Parameters
match_dataPointer to match data.
Returns
Reference to the calling RegexReplace object.

◆ setModifier()

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

Set the modifier string (resets all JPCRE2 and PCRE2 options) by calling RegexReplace::changeModifier().

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

◆ setModifierTable()

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

Set a custom modifier table to be used.

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

◆ setPcre2Option()

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

Set PCRE2 option replace (overwrite existing option)

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

◆ setRegexObject()

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

Set the associated Regex object.

Regex object is not modified.

Parameters
rPointer to a Regex object.
Returns
Reference to the calling RegexReplace object.

◆ setReplaceCounter()

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::setReplaceCounter ( SIZE_T counter)
inline

Set an external counter variable to store the replacement count.

This counter will be updated after each replacement operation on this object. A call to this method will reset the internal counter to 0, thus when you reset the counter to internal counter (by giving null as param), the previous replace count won't be available.

Parameters
counterPointer to a counter variable. Null sets the counter to default internal counter.
Returns
Reference to the calling RegexReplace object.

◆ setReplaceWith() [1/2]

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

Set the replacement string.

$ is a special character which implies captured group.

  1. A numbered substring can be referenced with $n or ${n} where n is the group number.
  2. A named substring can be referenced with ${name}, where 'name' is the group name.
  3. A literal $ can be given as $$.

Note: This function makes a copy of the string. If no copy is desired or you are working with big text, consider passing the string with pointer.

Parameters
sString to replace with
Returns
Reference to the calling RegexReplace object

◆ setReplaceWith() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::setReplaceWith ( String const *  s)
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 the string to replace with, null pointer unsets it.
Returns
Reference to the calling RegexReplace object

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

+ Here is the call graph for this function:

◆ setStartOffset()

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::setStartOffset ( PCRE2_SIZE  start_offset)
inline

Set start offset.

Set the offset where matching starts for replace operation

Parameters
start_offsetThe offset where matching starts for replace operation
Returns
Reference to the calling RegexReplace object

◆ setSubject() [1/2]

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

Set the subject string for replace.

This makes a copy of the string. If no copy is desired or you are working with big text, consider passing by pointer.

Parameters
sSubject string
Returns
Reference to the calling RegexReplace object
See also
RegexMatch::setSubject()

◆ setSubject() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
RegexReplace& jpcre2::select< Char_T, Map >::RegexReplace::setSubject ( String s)
inline

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

Set pointer to the subject string for replace, null pointer unsets it. The underlined data is not modified unless RegexReplace::preplace() method is used.

Parameters
sPointer to subject string
Returns
Reference to the calling RegexReplace object
See also
RegexMatch::setSubject()

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

+ Here is the call graph for this function: