regex.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
* Copyright (C) 2002-2016, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: regex.h
* encoding: UTF-8
* indentation:4
*
* created on: 2002oct22
* created by: Andy Heninger
*
* ICU Regular Expressions, API for C++
*/
#ifndef REGEX_H
#define REGEX_H
//#define REGEX_DEBUG
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
#include "unicode/uobject.h"
#include "unicode/unistr.h"
#include "unicode/utext.h"
#include "unicode/parseerr.h"
#include "unicode/uregex.h"
// Forward Declarations
struct UHashtable;
U_NAMESPACE_BEGIN
struct Regex8BitSet;
class RegexCImpl;
class RegexMatcher;
class RegexPattern;
struct REStackFrame;
class BreakIterator;
class UnicodeSet;
class UVector;
class UVector32;
class UVector64;
class U_I18N_API RegexPattern final : public UObject {
public:
RegexPattern();
RegexPattern(const RegexPattern &source);
virtual ~RegexPattern();
bool operator==(const RegexPattern& that) const;
inline bool operator!=(const RegexPattern& that) const {return ! operator ==(that);}
RegexPattern &operator =(const RegexPattern &source);
virtual RegexPattern *clone() const;
static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,
UParseError &pe,
UErrorCode &status);
static RegexPattern * U_EXPORT2 compile( UText *regex,
UParseError &pe,
UErrorCode &status);
static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,
uint32_t flags,
UParseError &pe,
UErrorCode &status);
static RegexPattern * U_EXPORT2 compile( UText *regex,
uint32_t flags,
UParseError &pe,
UErrorCode &status);
static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,
uint32_t flags,
UErrorCode &status);
static RegexPattern * U_EXPORT2 compile( UText *regex,
uint32_t flags,
UErrorCode &status);
virtual uint32_t flags() const;
virtual RegexMatcher *matcher(const UnicodeString &input,
UErrorCode &status) const;
private:
RegexMatcher *matcher(const char16_t *input,
UErrorCode &status) const = delete;
public:
virtual RegexMatcher *matcher(UErrorCode &status) const;
static UBool U_EXPORT2 matches(const UnicodeString &regex,
const UnicodeString &input,
UParseError &pe,
UErrorCode &status);
static UBool U_EXPORT2 matches(UText *regex,
UText *input,
UParseError &pe,
UErrorCode &status);
virtual UnicodeString pattern() const;
virtual UText *patternText(UErrorCode &status) const;
virtual int32_t groupNumberFromName(const UnicodeString &groupName, UErrorCode &status) const;
virtual int32_t groupNumberFromName(const char *groupName, int32_t nameLength, UErrorCode &status) const;
virtual int32_t split(const UnicodeString &input,
UnicodeString dest[],
int32_t destCapacity,
UErrorCode &status) const;
virtual int32_t split(UText *input,
UText *dest[],
int32_t destCapacity,
UErrorCode &status) const;
virtual UClassID getDynamicClassID() const override;
static UClassID U_EXPORT2 getStaticClassID();
private:
//
// Implementation Data
//
UText *fPattern; // The original pattern string.
UnicodeString *fPatternString; // The original pattern UncodeString if relevant
uint32_t fFlags; // The flags used when compiling the pattern.
//
UVector64 *fCompiledPat; // The compiled pattern p-code.
UnicodeString fLiteralText; // Any literal string data from the pattern,
// after un-escaping, for use during the match.
UVector *fSets; // Any UnicodeSets referenced from the pattern.
Regex8BitSet *fSets8; // (and fast sets for latin-1 range.)
UErrorCode fDeferredStatus; // status if some prior error has left this
// RegexPattern in an unusable state.
int32_t fMinMatchLen; // Minimum Match Length. All matches will have length
// >= this value. For some patterns, this calculated
// value may be less than the true shortest
// possible match.
int32_t fFrameSize; // Size of a state stack frame in the
// execution engine.
int32_t fDataSize; // The size of the data needed by the pattern that
// does not go on the state stack, but has just
// a single copy per matcher.
UVector32 *fGroupMap; // Map from capture group number to position of
// the group's variables in the matcher stack frame.
int32_t fStartType; // Info on how a match must start.
int32_t fInitialStringIdx; //
int32_t fInitialStringLen;
UnicodeSet *fInitialChars;
UChar32 fInitialChar;
Regex8BitSet *fInitialChars8;
UBool fNeedsAltInput;
UHashtable *fNamedCaptureMap; // Map from capture group names to numbers.
friend class RegexCompile;
friend class RegexMatcher;
friend class RegexCImpl;
//
// Implementation Methods
//
void init(); // Common initialization, for use by constructors.
bool initNamedCaptureMap(); // Lazy init for fNamedCaptureMap.
void zap(); // Common cleanup
void dumpOp(int32_t index) const;
public:
#ifndef U_HIDE_INTERNAL_API
void dumpPattern() const;
#endif /* U_HIDE_INTERNAL_API */
};
class U_I18N_API RegexMatcher final : public UObject {
public:
RegexMatcher(const UnicodeString &regexp, uint32_t flags, UErrorCode &status);
RegexMatcher(UText *regexp, uint32_t flags, UErrorCode &status);
RegexMatcher(const UnicodeString &regexp, const UnicodeString &input,
uint32_t flags, UErrorCode &status);
RegexMatcher(UText *regexp, UText *input,
uint32_t flags, UErrorCode &status);
private:
RegexMatcher(const UnicodeString &regexp, const char16_t *input,
uint32_t flags, UErrorCode &status) = delete;
public:
virtual ~RegexMatcher();
virtual UBool matches(UErrorCode &status);
virtual UBool matches(int64_t startIndex, UErrorCode &status);
virtual UBool lookingAt(UErrorCode &status);
virtual UBool lookingAt(int64_t startIndex, UErrorCode &status);
virtual UBool find();
virtual UBool find(UErrorCode &status);
virtual UBool find(int64_t start, UErrorCode &status);
virtual UnicodeString group(UErrorCode &status) const;
virtual UnicodeString group(int32_t groupNum, UErrorCode &status) const;
virtual int32_t groupCount() const;
virtual UText *group(UText *dest, int64_t &group_len, UErrorCode &status) const;
virtual UText *group(int32_t groupNum, UText *dest, int64_t &group_len, UErrorCode &status) const;
virtual int32_t start(UErrorCode &status) const;
virtual int64_t start64(UErrorCode &status) const;
virtual int32_t start(int32_t group, UErrorCode &status) const;
virtual int64_t start64(int32_t group, UErrorCode &status) const;
virtual int32_t end(UErrorCode &status) const;
virtual int64_t end64(UErrorCode &status) const;
virtual int32_t end(int32_t group, UErrorCode &status) const;
virtual int64_t end64(int32_t group, UErrorCode &status) const;
virtual RegexMatcher &reset();
virtual RegexMatcher &reset(int64_t index, UErrorCode &status);
virtual RegexMatcher &reset(const UnicodeString &input);
virtual RegexMatcher &reset(UText *input);
virtual RegexMatcher &refreshInputText(UText *input, UErrorCode &status);
private:
RegexMatcher &reset(const char16_t *input) = delete;
public:
virtual const UnicodeString &input() const;
virtual UText *inputText() const;
virtual UText *getInput(UText *dest, UErrorCode &status) const;
virtual RegexMatcher &region(int64_t start, int64_t limit, UErrorCode &status);
virtual RegexMatcher &region(int64_t regionStart, int64_t regionLimit, int64_t startIndex, UErrorCode &status);
virtual int32_t regionStart() const;
virtual int64_t regionStart64() const;
virtual int32_t regionEnd() const;
virtual int64_t regionEnd64() const;
virtual UBool hasTransparentBounds() const;
virtual RegexMatcher &useTransparentBounds(UBool b);
virtual UBool hasAnchoringBounds() const;
virtual RegexMatcher &useAnchoringBounds(UBool b);
virtual UBool hitEnd() const;
virtual UBool requireEnd() const;
virtual const RegexPattern &pattern() const;
virtual UnicodeString replaceAll(const UnicodeString &replacement, UErrorCode &status);
virtual UText *replaceAll(UText *replacement, UText *dest, UErrorCode &status);
virtual UnicodeString replaceFirst(const UnicodeString &replacement, UErrorCode &status);
virtual UText *replaceFirst(UText *replacement, UText *dest, UErrorCode &status);
virtual RegexMatcher &appendReplacement(UnicodeString &dest,
const UnicodeString &replacement, UErrorCode &status);
virtual RegexMatcher &appendReplacement(UText *dest,
UText *replacement, UErrorCode &status);
virtual UnicodeString &appendTail(UnicodeString &dest);
virtual UText *appendTail(UText *dest, UErrorCode &status);
virtual int32_t split(const UnicodeString &input,
UnicodeString dest[],
int32_t destCapacity,
UErrorCode &status);
virtual int32_t split(UText *input,
UText *dest[],
int32_t destCapacity,
UErrorCode &status);
virtual void setTimeLimit(int32_t limit, UErrorCode &status);
virtual int32_t getTimeLimit() const;
virtual void setStackLimit(int32_t limit, UErrorCode &status);
virtual int32_t getStackLimit() const;
virtual void setMatchCallback(URegexMatchCallback *callback,
const void *context,
UErrorCode &status);
virtual void getMatchCallback(URegexMatchCallback *&callback,
const void *&context,
UErrorCode &status);
virtual void setFindProgressCallback(URegexFindProgressCallback *callback,
const void *context,
UErrorCode &status);
virtual void getFindProgressCallback(URegexFindProgressCallback *&callback,
const void *&context,
UErrorCode &status);
#ifndef U_HIDE_INTERNAL_API
void setTrace(UBool state);
#endif /* U_HIDE_INTERNAL_API */
static UClassID U_EXPORT2 getStaticClassID();
virtual UClassID getDynamicClassID() const override;
private:
// Constructors and other object boilerplate are private.
// Instances of RegexMatcher can not be assigned, copied, cloned, etc.
RegexMatcher() = delete; // default constructor not implemented
RegexMatcher(const RegexPattern *pat);
RegexMatcher(const RegexMatcher &other) = delete;
RegexMatcher &operator =(const RegexMatcher &rhs) = delete;
void init(UErrorCode &status); // Common initialization
void init2(UText *t, UErrorCode &e); // Common initialization, part 2.
friend class RegexPattern;
friend class RegexCImpl;
public:
#ifndef U_HIDE_INTERNAL_API
void resetPreserveRegion(); // Reset matcher state, but preserve any region.
#endif /* U_HIDE_INTERNAL_API */
private:
//
// MatchAt This is the internal interface to the match engine itself.
// Match status comes back in matcher member variables.
//
void MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status);
inline void backTrack(int64_t &inputIdx, int32_t &patIdx);
UBool isWordBoundary(int64_t pos); // perform Perl-like \b test
UBool isUWordBoundary(int64_t pos, UErrorCode &status); // perform RBBI based \b test
// Find a grapheme cluster boundary using a break iterator. For handling \X in regexes.
int64_t followingGCBoundary(int64_t pos, UErrorCode &status);
REStackFrame *resetStack();
inline REStackFrame *StateSave(REStackFrame *fp, int64_t savePatIdx, UErrorCode &status);
void IncrementTime(UErrorCode &status);
// Call user find callback function, if set. Return true if operation should be interrupted.
inline UBool findProgressInterrupt(int64_t matchIndex, UErrorCode &status);
int64_t appendGroup(int32_t groupNum, UText *dest, UErrorCode &status) const;
UBool findUsingChunk(UErrorCode &status);
void MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &status);
UBool isChunkWordBoundary(int32_t pos);
const RegexPattern *fPattern;
RegexPattern *fPatternOwned; // Non-nullptr if this matcher owns the pattern, and
// should delete it when through.
const UnicodeString *fInput; // The string being matched. Only used for input()
UText *fInputText; // The text being matched. Is never nullptr.
UText *fAltInputText; // A shallow copy of the text being matched.
// Only created if the pattern contains backreferences.
int64_t fInputLength; // Full length of the input text.
int32_t fFrameSize; // The size of a frame in the backtrack stack.
int64_t fRegionStart; // Start of the input region, default = 0.
int64_t fRegionLimit; // End of input region, default to input.length.
int64_t fAnchorStart; // Region bounds for anchoring operations (^ or $).
int64_t fAnchorLimit; // See useAnchoringBounds
int64_t fLookStart; // Region bounds for look-ahead/behind and
int64_t fLookLimit; // and other boundary tests. See
// useTransparentBounds
int64_t fActiveStart; // Currently active bounds for matching.
int64_t fActiveLimit; // Usually is the same as region, but
// is changed to fLookStart/Limit when
// entering look around regions.
UBool fTransparentBounds; // True if using transparent bounds.
UBool fAnchoringBounds; // True if using anchoring bounds.
UBool fMatch; // True if the last attempted match was successful.
int64_t fMatchStart; // Position of the start of the most recent match
int64_t fMatchEnd; // First position after the end of the most recent match
// Zero if no previous match, even when a region
// is active.
int64_t fLastMatchEnd; // First position after the end of the previous match,
// or -1 if there was no previous match.
int64_t fAppendPosition; // First position after the end of the previous
// appendReplacement(). As described by the
// JavaDoc for Java Matcher, where it is called
// "append position"
UBool fHitEnd; // True if the last match touched the end of input.
UBool fRequireEnd; // True if the last match required end-of-input
// (matched $ or Z)
UVector64 *fStack;
REStackFrame *fFrame; // After finding a match, the last active stack frame,
// which will contain the capture group results.
// NOT valid while match engine is running.
int64_t *fData; // Data area for use by the compiled pattern.
int64_t fSmallData[8]; // Use this for data if it's enough.
int32_t fTimeLimit; // Max time (in arbitrary steps) to let the
// match engine run. Zero for unlimited.
int32_t fTime; // Match time, accumulates while matching.
int32_t fTickCounter; // Low bits counter for time. Counts down StateSaves.
// Kept separately from fTime to keep as much
// code as possible out of the inline
// StateSave function.
int32_t fStackLimit; // Maximum memory size to use for the backtrack
// stack, in bytes. Zero for unlimited.
URegexMatchCallback *fCallbackFn; // Pointer to match progress callback funct.
// nullptr if there is no callback.
const void *fCallbackContext; // User Context ptr for callback function.
URegexFindProgressCallback *fFindProgressCallbackFn; // Pointer to match progress callback funct.
// nullptr if there is no callback.
const void *fFindProgressCallbackContext; // User Context ptr for callback function.
UBool fInputUniStrMaybeMutable; // Set when fInputText wraps a UnicodeString that may be mutable - compatibility.
UBool fTraceDebug; // Set true for debug tracing of match engine.
UErrorCode fDeferredStatus; // Save error state that cannot be immediately
// reported, or that permanently disables this matcher.
BreakIterator *fWordBreakItr;
BreakIterator *fGCBreakItr;
};
U_NAMESPACE_END
#endif // UCONFIG_NO_REGULAR_EXPRESSIONS
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text.
Definition: brkiter.h:106
icu::RegexMatcher
class RegexMatcher bundles together a regular expression pattern and input text to which the expressi...
Definition: regex.h:659
icu::RegexMatcher::end64
virtual int64_t end64(int32_t group, UErrorCode &status) const
Returns the index in the input string of the character following the text matched by the specified ca...
icu::RegexMatcher::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::RegexMatcher::hasTransparentBounds
virtual UBool hasTransparentBounds() const
Queries the transparency of region bounds for this matcher.
icu::RegexMatcher::resetPreserveRegion
void resetPreserveRegion()
icu::RegexMatcher::hasAnchoringBounds
virtual UBool hasAnchoringBounds() const
Return true if this matcher is using anchoring bounds.
icu::RegexMatcher::end
virtual int32_t end(UErrorCode &status) const
Returns the index in the input string of the first character following the text matched during the pr...
icu::RegexMatcher::reset
virtual RegexMatcher & reset(const UnicodeString &input)
Resets this matcher with a new input string.
icu::RegexMatcher::replaceFirst
virtual UnicodeString replaceFirst(const UnicodeString &replacement, UErrorCode &status)
Replaces the first substring of the input that matches the pattern with the replacement string.
icu::RegexMatcher::getMatchCallback
virtual void getMatchCallback(URegexMatchCallback *&callback, const void *&context, UErrorCode &status)
Get the callback function for this URegularExpression.
icu::RegexMatcher::groupCount
virtual int32_t groupCount() const
Returns the number of capturing groups in this matcher's pattern.
icu::RegexMatcher::group
virtual UnicodeString group(UErrorCode &status) const
Returns a string containing the text matched by the previous match.
icu::RegexMatcher::replaceAll
virtual UnicodeString replaceAll(const UnicodeString &replacement, UErrorCode &status)
Replaces every substring of the input that matches the pattern with the given replacement string.
icu::RegexMatcher::setFindProgressCallback
virtual void setFindProgressCallback(URegexFindProgressCallback *callback, const void *context, UErrorCode &status)
Set a progress callback function for use with find operations on this Matcher.
icu::RegexMatcher::reset
virtual RegexMatcher & reset()
Resets this matcher.
icu::RegexMatcher::getInput
virtual UText * getInput(UText *dest, UErrorCode &status) const
Returns the input string being matched, either by copying it into the provided UText parameter or by ...
icu::RegexMatcher::split
virtual int32_t split(const UnicodeString &input, UnicodeString dest[], int32_t destCapacity, UErrorCode &status)
Split a string into fields.
icu::RegexMatcher::lookingAt
virtual UBool lookingAt(int64_t startIndex, UErrorCode &status)
Attempts to match the input string, starting from the specified index, against the pattern.
icu::RegexMatcher::matches
virtual UBool matches(int64_t startIndex, UErrorCode &status)
Resets the matcher, then attempts to match the input beginning at the specified startIndex,...
icu::RegexMatcher::start
virtual int32_t start(UErrorCode &status) const
Returns the index in the input string of the start of the text matched during the previous match oper...
icu::RegexMatcher::find
virtual UBool find()
Find the next pattern match in the input string.
icu::RegexMatcher::RegexMatcher
RegexMatcher(UText *regexp, UText *input, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
icu::RegexMatcher::pattern
virtual const RegexPattern & pattern() const
Returns the pattern that is interpreted by this matcher.
icu::RegexMatcher::region
virtual RegexMatcher & region(int64_t start, int64_t limit, UErrorCode &status)
Sets the limits of this matcher's region.
icu::RegexMatcher::refreshInputText
virtual RegexMatcher & refreshInputText(UText *input, UErrorCode &status)
Set the subject text string upon which the regular expression is looking for matches without changing...
icu::RegexMatcher::RegexMatcher
RegexMatcher(const UnicodeString &regexp, const UnicodeString &input, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
icu::RegexMatcher::getTimeLimit
virtual int32_t getTimeLimit() const
Get the time limit, if any, for match operations made with this Matcher.
icu::RegexMatcher::group
virtual UText * group(int32_t groupNum, UText *dest, int64_t &group_len, UErrorCode &status) const
Returns a shallow clone of the entire live input string with the UText current native index set to th...
icu::RegexMatcher::setTimeLimit
virtual void setTimeLimit(int32_t limit, UErrorCode &status)
Set a processing time limit for match operations with this Matcher.
icu::RegexMatcher::setMatchCallback
virtual void setMatchCallback(URegexMatchCallback *callback, const void *context, UErrorCode &status)
Set a callback function for use with this Matcher.
icu::RegexMatcher::regionStart64
virtual int64_t regionStart64() const
Reports the start index of this matcher's region.
icu::RegexMatcher::start
virtual int32_t start(int32_t group, UErrorCode &status) const
Returns the index in the input string of the start of the text matched by the specified capture group...
icu::RegexMatcher::appendTail
virtual UnicodeString & appendTail(UnicodeString &dest)
As the final step in a find-and-replace operation, append the remainder of the input string,...
icu::RegexMatcher::reset
virtual RegexMatcher & reset(UText *input)
Resets this matcher with a new input string.
icu::RegexMatcher::~RegexMatcher
virtual ~RegexMatcher()
Destructor.
icu::RegexMatcher::lookingAt
virtual UBool lookingAt(UErrorCode &status)
Attempts to match the input string, starting from the beginning of the region, against the pattern.
icu::RegexMatcher::input
virtual const UnicodeString & input() const
Returns the input string being matched.
icu::RegexMatcher::replaceAll
virtual UText * replaceAll(UText *replacement, UText *dest, UErrorCode &status)
Replaces every substring of the input that matches the pattern with the given replacement string.
icu::RegexMatcher::region
virtual RegexMatcher & region(int64_t regionStart, int64_t regionLimit, int64_t startIndex, UErrorCode &status)
Identical to region(start, limit, status) but also allows a start position without resetting the regi...
icu::RegexMatcher::reset
virtual RegexMatcher & reset(int64_t index, UErrorCode &status)
Resets this matcher, and set the current input position.
icu::RegexMatcher::regionEnd64
virtual int64_t regionEnd64() const
Reports the end (limit) index (exclusive) of this matcher's region.
icu::RegexMatcher::find
virtual UBool find(UErrorCode &status)
Find the next pattern match in the input string.
icu::RegexMatcher::RegexMatcher
RegexMatcher(UText *regexp, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
icu::RegexMatcher::useAnchoringBounds
virtual RegexMatcher & useAnchoringBounds(UBool b)
Set whether this matcher is using Anchoring Bounds for its region.
icu::RegexMatcher::matches
virtual UBool matches(UErrorCode &status)
Attempts to match the entire input region against the pattern.
icu::RegexMatcher::appendReplacement
virtual RegexMatcher & appendReplacement(UnicodeString &dest, const UnicodeString &replacement, UErrorCode &status)
Implements a replace operation intended to be used as part of an incremental find-and-replace.
icu::RegexMatcher::setTrace
void setTrace(UBool state)
setTrace Debug function, enable/disable tracing of the matching engine.
icu::RegexMatcher::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::RegexMatcher::split
virtual int32_t split(UText *input, UText *dest[], int32_t destCapacity, UErrorCode &status)
Split a string into fields.
icu::RegexMatcher::RegexMatcher
RegexMatcher(const UnicodeString &regexp, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
icu::RegexMatcher::useTransparentBounds
virtual RegexMatcher & useTransparentBounds(UBool b)
Sets the transparency of region bounds for this matcher.
icu::RegexMatcher::getStackLimit
virtual int32_t getStackLimit() const
Get the size of the heap storage available for use by the back tracking stack.
icu::RegexMatcher::end
virtual int32_t end(int32_t group, UErrorCode &status) const
Returns the index in the input string of the character following the text matched by the specified ca...
icu::RegexMatcher::group
virtual UText * group(UText *dest, int64_t &group_len, UErrorCode &status) const
Returns a shallow clone of the entire live input string with the UText current native index set to th...
icu::RegexMatcher::start64
virtual int64_t start64(UErrorCode &status) const
Returns the index in the input string of the start of the text matched during the previous match oper...
icu::RegexMatcher::end64
virtual int64_t end64(UErrorCode &status) const
Returns the index in the input string of the first character following the text matched during the pr...
icu::RegexMatcher::replaceFirst
virtual UText * replaceFirst(UText *replacement, UText *dest, UErrorCode &status)
Replaces the first substring of the input that matches the pattern with the replacement string.
icu::RegexMatcher::setStackLimit
virtual void setStackLimit(int32_t limit, UErrorCode &status)
Set the amount of heap storage available for use by the match backtracking stack.
icu::RegexMatcher::regionEnd
virtual int32_t regionEnd() const
Reports the end (limit) index (exclusive) of this matcher's region.
icu::RegexMatcher::inputText
virtual UText * inputText() const
Returns the input string being matched.
icu::RegexMatcher::appendReplacement
virtual RegexMatcher & appendReplacement(UText *dest, UText *replacement, UErrorCode &status)
Implements a replace operation intended to be used as part of an incremental find-and-replace.
icu::RegexMatcher::start64
virtual int64_t start64(int32_t group, UErrorCode &status) const
Returns the index in the input string of the start of the text matched by the specified capture group...
icu::RegexMatcher::getFindProgressCallback
virtual void getFindProgressCallback(URegexFindProgressCallback *&callback, const void *&context, UErrorCode &status)
Get the find progress callback function for this URegularExpression.
icu::RegexMatcher::hitEnd
virtual UBool hitEnd() const
Return true if the most recent matching operation attempted to access additional input beyond the ava...
icu::RegexMatcher::appendTail
virtual UText * appendTail(UText *dest, UErrorCode &status)
As the final step in a find-and-replace operation, append the remainder of the input string,...
icu::RegexMatcher::requireEnd
virtual UBool requireEnd() const
Return true the most recent match succeeded and additional input could cause it to fail.
icu::RegexMatcher::find
virtual UBool find(int64_t start, UErrorCode &status)
Resets this RegexMatcher and then attempts to find the next substring of the input string that matche...
icu::RegexMatcher::regionStart
virtual int32_t regionStart() const
Reports the start index of this matcher's region.
icu::RegexMatcher::group
virtual UnicodeString group(int32_t groupNum, UErrorCode &status) const
Returns a string containing the text captured by the given group during the previous match operation.
icu::RegexPattern
Class RegexPattern represents a compiled regular expression.
Definition: regex.h:87
icu::RegexPattern::compile
static RegexPattern * compile(UText *regex, uint32_t flags, UParseError &pe, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object using the specified URegexp...
icu::RegexPattern::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::RegexPattern::~RegexPattern
virtual ~RegexPattern()
Destructor.
icu::RegexPattern::flags
virtual uint32_t flags() const
Get the URegexpFlag match mode flags that were used when compiling this pattern.
icu::RegexPattern::dumpPattern
void dumpPattern() const
Dump a compiled pattern.
icu::RegexPattern::clone
virtual RegexPattern * clone() const
Create an exact copy of this RegexPattern object.
icu::RegexPattern::matches
static UBool matches(UText *regex, UText *input, UParseError &pe, UErrorCode &status)
Test whether a string matches a regular expression.
icu::RegexPattern::compile
static RegexPattern * compile(const UnicodeString &regex, UParseError &pe, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object.
icu::RegexPattern::operator!=
bool operator!=(const RegexPattern &that) const
Comparison operator.
Definition: regex.h:132
icu::RegexPattern::compile
static RegexPattern * compile(UText *regex, uint32_t flags, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object using the specified URegexp...
icu::RegexPattern::patternText
virtual UText * patternText(UErrorCode &status) const
Returns the regular expression from which this pattern was compiled.
icu::RegexPattern::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::RegexPattern::split
virtual int32_t split(const UnicodeString &input, UnicodeString dest[], int32_t destCapacity, UErrorCode &status) const
Split a string into fields.
icu::RegexPattern::split
virtual int32_t split(UText *input, UText *dest[], int32_t destCapacity, UErrorCode &status) const
Split a string into fields.
icu::RegexPattern::matcher
virtual RegexMatcher * matcher(const UnicodeString &input, UErrorCode &status) const
Creates a RegexMatcher that will match the given input against this pattern.
icu::RegexPattern::compile
static RegexPattern * compile(const UnicodeString &regex, uint32_t flags, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object using the specified URegexp...
icu::RegexPattern::compile
static RegexPattern * compile(const UnicodeString &regex, uint32_t flags, UParseError &pe, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object using the specified URegexp...
icu::RegexPattern::matches
static UBool matches(const UnicodeString &regex, const UnicodeString &input, UParseError &pe, UErrorCode &status)
Test whether a string matches a regular expression.
icu::RegexPattern::groupNumberFromName
virtual int32_t groupNumberFromName(const UnicodeString &groupName, UErrorCode &status) const
Get the group number corresponding to a named capture group.
icu::RegexPattern::RegexPattern
RegexPattern(const RegexPattern &source)
Copy Constructor.
icu::RegexPattern::compile
static RegexPattern * compile(UText *regex, UParseError &pe, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object.
icu::RegexPattern::operator==
bool operator==(const RegexPattern &that) const
Comparison operator.
icu::RegexPattern::RegexPattern
RegexPattern()
default constructor.
icu::RegexPattern::pattern
virtual UnicodeString pattern() const
Returns the regular expression from which this pattern was compiled.
icu::RegexPattern::matcher
virtual RegexMatcher * matcher(UErrorCode &status) const
Creates a RegexMatcher that will match against this pattern.
icu::RegexPattern::groupNumberFromName
virtual int32_t groupNumberFromName(const char *groupName, int32_t nameLength, UErrorCode &status) const
Get the group number corresponding to a named capture group.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UnicodeSet
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:285
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
UHashtable
struct UHashtable UHashtable
Definition: msgfmt.h:43
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
parseerr.h
C API: Parse Error Information.
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
UText
UText struct.
Definition: utext.h:1328
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:435
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247
unistr.h
C++ API: Unicode String.
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
uregex.h
C API: Regular Expressions.
URegexFindProgressCallback
UBool URegexFindProgressCallback(const void *context, int64_t matchIndex)
Function pointer for a regular expression find callback function.
Definition: uregex.h:1576
URegexMatchCallback
UBool URegexMatchCallback(const void *context, int32_t steps)
Function pointer for a regular expression matching callback function.
Definition: uregex.h:1502
utext.h
C API: Abstract Unicode Text API.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:301