Loading...
Searching...
No Matches
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);
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);
uint32_t flags() const;
RegexMatcher *matcher(const UnicodeString &input,
UErrorCode &status) const;
private:
RegexMatcher *matcher(const char16_t *input,
UErrorCode &status) const = delete;
public:
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);
UnicodeString pattern() const;
UText *patternText(UErrorCode &status) const;
int32_t groupNumberFromName(const UnicodeString &groupName, UErrorCode &status) const;
int32_t groupNumberFromName(const char *groupName, int32_t nameLength, UErrorCode &status) const;
int32_t split(const UnicodeString &input,
UnicodeString dest[],
int32_t destCapacity,
UErrorCode &status) const;
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();
UBool matches(UErrorCode &status);
UBool matches(int64_t startIndex, UErrorCode &status);
UBool lookingAt(UErrorCode &status);
UBool lookingAt(int64_t startIndex, UErrorCode &status);
UBool find();
UBool find(UErrorCode &status);
UBool find(int64_t start, UErrorCode &status);
UnicodeString group(UErrorCode &status) const;
UnicodeString group(int32_t groupNum, UErrorCode &status) const;
int32_t groupCount() const;
UText *group(UText *dest, int64_t &group_len, UErrorCode &status) const;
UText *group(int32_t groupNum, UText *dest, int64_t &group_len, UErrorCode &status) const;
int32_t start(UErrorCode &status) const;
int64_t start64(UErrorCode &status) const;
int32_t start(int32_t group, UErrorCode &status) const;
int64_t start64(int32_t group, UErrorCode &status) const;
int32_t end(UErrorCode &status) const;
int64_t end64(UErrorCode &status) const;
int32_t end(int32_t group, UErrorCode &status) const;
int64_t end64(int32_t group, UErrorCode &status) const;
RegexMatcher &reset();
RegexMatcher &reset(int64_t index, UErrorCode &status);
RegexMatcher &reset(const UnicodeString &input);
RegexMatcher &reset(UText *input);
RegexMatcher &refreshInputText(UText *input, UErrorCode &status);
private:
RegexMatcher &reset(const char16_t *input) = delete;
public:
const UnicodeString &input() const;
UText *inputText() const;
UText *getInput(UText *dest, UErrorCode &status) const;
RegexMatcher &region(int64_t start, int64_t limit, UErrorCode &status);
RegexMatcher &region(int64_t regionStart, int64_t regionLimit, int64_t startIndex, UErrorCode &status);
int32_t regionStart() const;
int64_t regionStart64() const;
int32_t regionEnd() const;
int64_t regionEnd64() const;
UBool hasTransparentBounds() const;
RegexMatcher &useTransparentBounds(UBool b);
UBool hasAnchoringBounds() const;
RegexMatcher &useAnchoringBounds(UBool b);
UBool hitEnd() const;
UBool requireEnd() const;
const RegexPattern &pattern() const;
UnicodeString replaceAll(const UnicodeString &replacement, UErrorCode &status);
UText *replaceAll(UText *replacement, UText *dest, UErrorCode &status);
UnicodeString replaceFirst(const UnicodeString &replacement, UErrorCode &status);
UText *replaceFirst(UText *replacement, UText *dest, UErrorCode &status);
RegexMatcher &appendReplacement(UnicodeString &dest,
const UnicodeString &replacement, UErrorCode &status);
RegexMatcher &appendReplacement(UText *dest,
UText *replacement, UErrorCode &status);
UnicodeString &appendTail(UnicodeString &dest);
UText *appendTail(UText *dest, UErrorCode &status);
int32_t split(const UnicodeString &input,
UnicodeString dest[],
int32_t destCapacity,
UErrorCode &status);
int32_t split(UText *input,
UText *dest[],
int32_t destCapacity,
UErrorCode &status);
void setTimeLimit(int32_t limit, UErrorCode &status);
int32_t getTimeLimit() const;
void setStackLimit(int32_t limit, UErrorCode &status);
int32_t getStackLimit() const;
void setMatchCallback(URegexMatchCallback *callback,
const void *context,
UErrorCode &status);
void getMatchCallback(URegexMatchCallback *&callback,
const void *&context,
UErrorCode &status);
void setFindProgressCallback(URegexFindProgressCallback *callback,
const void *context,
UErrorCode &status);
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::hasTransparentBounds
UBool hasTransparentBounds() const
Queries the transparency of region bounds for this matcher.
icu::RegexMatcher::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::RegexMatcher::lookingAt
UBool lookingAt(UErrorCode &status)
Attempts to match the input string, starting from the beginning of the region, against the pattern.
icu::RegexMatcher::group
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::resetPreserveRegion
void resetPreserveRegion()
icu::RegexMatcher::regionStart64
int64_t regionStart64() const
Reports the start index of this matcher's region.
icu::RegexMatcher::replaceAll
UnicodeString replaceAll(const UnicodeString &replacement, UErrorCode &status)
Replaces every substring of the input that matches the pattern with the given replacement string.
icu::RegexMatcher::appendTail
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::group
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::getFindProgressCallback
void getFindProgressCallback(URegexFindProgressCallback *&callback, const void *&context, UErrorCode &status)
Get the find progress callback function for this URegularExpression.
icu::RegexMatcher::matches
UBool matches(UErrorCode &status)
Attempts to match the entire input region against the pattern.
icu::RegexMatcher::getInput
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::hasAnchoringBounds
UBool hasAnchoringBounds() const
Return true if this matcher is using anchoring bounds.
icu::RegexMatcher::appendReplacement
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::start64
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::useAnchoringBounds
RegexMatcher & useAnchoringBounds(UBool b)
Set whether this matcher is using Anchoring Bounds for its region.
icu::RegexMatcher::hitEnd
UBool hitEnd() const
Return true if the most recent matching operation attempted to access additional input beyond the ava...
icu::RegexMatcher::start
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::requireEnd
UBool requireEnd() const
Return true the most recent match succeeded and additional input could cause it to fail.
icu::RegexMatcher::end64
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::regionStart
int32_t regionStart() const
Reports the start index of this matcher's region.
icu::RegexMatcher::split
int32_t split(UText *input, UText *dest[], int32_t destCapacity, UErrorCode &status)
Split a string into fields.
icu::RegexMatcher::find
UBool find(UErrorCode &status)
Find the next pattern match in the input string.
icu::RegexMatcher::groupCount
int32_t groupCount() const
Returns the number of capturing groups in this matcher's pattern.
icu::RegexMatcher::end
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::RegexMatcher
RegexMatcher(UText *regexp, UText *input, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
icu::RegexMatcher::getTimeLimit
int32_t getTimeLimit() const
Get the time limit, if any, for match operations made with this Matcher.
icu::RegexMatcher::end64
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::reset
RegexMatcher & reset()
Resets this matcher.
icu::RegexMatcher::RegexMatcher
RegexMatcher(const UnicodeString &regexp, const UnicodeString &input, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
icu::RegexMatcher::inputText
UText * inputText() const
Returns the input string being matched.
icu::RegexMatcher::setMatchCallback
void setMatchCallback(URegexMatchCallback *callback, const void *context, UErrorCode &status)
Set a callback function for use with this Matcher.
icu::RegexMatcher::replaceAll
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::setFindProgressCallback
void setFindProgressCallback(URegexFindProgressCallback *callback, const void *context, UErrorCode &status)
Set a progress callback function for use with find operations on this Matcher.
icu::RegexMatcher::setTimeLimit
void setTimeLimit(int32_t limit, UErrorCode &status)
Set a processing time limit for match operations with this Matcher.
icu::RegexMatcher::reset
RegexMatcher & reset(UText *input)
Resets this matcher with a new input string.
icu::RegexMatcher::end
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::regionEnd64
int64_t regionEnd64() const
Reports the end (limit) index (exclusive) of this matcher's region.
icu::RegexMatcher::appendTail
UnicodeString & appendTail(UnicodeString &dest)
As the final step in a find-and-replace operation, append the remainder of the input string,...
icu::RegexMatcher::matches
UBool matches(int64_t startIndex, UErrorCode &status)
Resets the matcher, then attempts to match the input beginning at the specified startIndex,...
icu::RegexMatcher::group
UnicodeString group(UErrorCode &status) const
Returns a string containing the text matched by the previous match.
icu::RegexMatcher::~RegexMatcher
virtual ~RegexMatcher()
Destructor.
icu::RegexMatcher::region
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::appendReplacement
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::start
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::getStackLimit
int32_t getStackLimit() const
Get the size of the heap storage available for use by the back tracking stack.
icu::RegexMatcher::refreshInputText
RegexMatcher & refreshInputText(UText *input, UErrorCode &status)
Set the subject text string upon which the regular expression is looking for matches without changing...
icu::RegexMatcher::split
int32_t split(const UnicodeString &input, UnicodeString dest[], int32_t destCapacity, UErrorCode &status)
Split a string into fields.
icu::RegexMatcher::RegexMatcher
RegexMatcher(UText *regexp, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
icu::RegexMatcher::setStackLimit
void setStackLimit(int32_t limit, UErrorCode &status)
Set the amount of heap storage available for use by the match backtracking stack.
icu::RegexMatcher::reset
RegexMatcher & reset(const UnicodeString &input)
Resets this matcher with a new input string.
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::replaceFirst
UnicodeString replaceFirst(const UnicodeString &replacement, UErrorCode &status)
Replaces the first substring of the input that matches the pattern with the replacement string.
icu::RegexMatcher::RegexMatcher
RegexMatcher(const UnicodeString &regexp, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
icu::RegexMatcher::find
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::useTransparentBounds
RegexMatcher & useTransparentBounds(UBool b)
Sets the transparency of region bounds for this matcher.
icu::RegexMatcher::input
const UnicodeString & input() const
Returns the input string being matched.
icu::RegexMatcher::group
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::RegexMatcher::pattern
const RegexPattern & pattern() const
Returns the pattern that is interpreted by this matcher.
icu::RegexMatcher::reset
RegexMatcher & reset(int64_t index, UErrorCode &status)
Resets this matcher, and set the current input position.
icu::RegexMatcher::regionEnd
int32_t regionEnd() const
Reports the end (limit) index (exclusive) of this matcher's region.
icu::RegexMatcher::lookingAt
UBool lookingAt(int64_t startIndex, UErrorCode &status)
Attempts to match the input string, starting from the specified index, against the pattern.
icu::RegexMatcher::replaceFirst
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::find
UBool find()
Find the next pattern match in the input string.
icu::RegexMatcher::start64
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::getMatchCallback
void getMatchCallback(URegexMatchCallback *&callback, const void *&context, UErrorCode &status)
Get the callback function for this URegularExpression.
icu::RegexMatcher::region
RegexMatcher & region(int64_t start, int64_t limit, UErrorCode &status)
Sets the limits of this matcher's region.
icu::RegexPattern::clone
RegexPattern * clone() const
Create an exact copy of this RegexPattern object.
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::split
int32_t split(UText *input, UText *dest[], int32_t destCapacity, UErrorCode &status) const
Split a string into fields.
icu::RegexPattern::matcher
RegexMatcher * matcher(UErrorCode &status) const
Creates a RegexMatcher that will match against this pattern.
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::dumpPattern
void dumpPattern() const
Dump a compiled pattern.
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(UText *regex, UText *input, UParseError &pe, UErrorCode &status)
Test whether a string matches a regular expression.
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::operator!=
bool operator!=(const RegexPattern &that) const
Comparison operator.
Definition regex.h:132
icu::RegexPattern::split
int32_t split(const UnicodeString &input, UnicodeString dest[], int32_t destCapacity, UErrorCode &status) const
Split a string into fields.
icu::RegexPattern::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::RegexPattern::patternText
UText * patternText(UErrorCode &status) const
Returns the regular expression from which this pattern was compiled.
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::matches
static UBool matches(const UnicodeString &regex, const UnicodeString &input, UParseError &pe, UErrorCode &status)
Test whether a string matches a regular expression.
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::groupNumberFromName
int32_t groupNumberFromName(const UnicodeString &groupName, UErrorCode &status) const
Get the group number corresponding to a named capture group.
icu::RegexPattern::groupNumberFromName
int32_t groupNumberFromName(const char *groupName, int32_t nameLength, UErrorCode &status) const
Get the group number corresponding to a named capture group.
icu::RegexPattern::RegexPattern
RegexPattern()
default constructor.
icu::RegexPattern::pattern
UnicodeString pattern() const
Returns the regular expression from which this pattern was compiled.
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::matcher
RegexMatcher * matcher(const UnicodeString &input, UErrorCode &status) const
Creates a RegexMatcher that will match the given input against this pattern.
icu::RegexPattern::flags
uint32_t flags() const
Get the URegexpFlag match mode flags that were used when compiling this pattern.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
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:303
UHashtable
struct UHashtable UHashtable
Definition msgfmt.h:43
icu::operator==
U_COMMON_API 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:449
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
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:509
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:316