Go to the documentation of this file.
47 #if U_SHOW_CPLUSPLUS_API
49 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
519 int32_t destCapacity,
563 int32_t destCapacity,
589 UVector64 *fCompiledPat;
594 Regex8BitSet *fSets8;
600 int32_t fMinMatchLen;
612 UVector32 *fGroupMap;
616 int32_t fInitialStringIdx;
617 int32_t fInitialStringLen;
620 Regex8BitSet *fInitialChars8;
621 UBool fNeedsAltInput;
625 friend class RegexCompile;
627 friend class RegexCImpl;
633 bool initNamedCaptureMap();
636 void dumpOp(int32_t index)
const;
639 #ifndef U_HIDE_INTERNAL_API
1567 int32_t destCapacity,
1596 int32_t destCapacity,
1677 const void *context,
1692 const void *&context,
1710 const void *context,
1725 const void *&context,
1728 #ifndef U_HIDE_INTERNAL_API
1762 friend class RegexCImpl;
1764 #ifndef U_HIDE_INTERNAL_API
1775 inline void backTrack(int64_t &inputIdx, int32_t &patIdx);
1776 UBool isWordBoundary(int64_t pos);
1779 int64_t followingGCBoundary(int64_t pos,
UErrorCode &status);
1780 REStackFrame *resetStack();
1781 inline REStackFrame *StateSave(REStackFrame *fp, int64_t savePatIdx,
UErrorCode &status);
1785 inline UBool findProgressInterrupt(int64_t matchIndex,
UErrorCode &status);
1787 int64_t appendGroup(int32_t groupNum,
UText *dest,
UErrorCode &status)
const;
1791 UBool isChunkWordBoundary(int32_t pos);
1799 UText *fAltInputText;
1801 int64_t fInputLength;
1804 int64_t fRegionStart;
1805 int64_t fRegionLimit;
1807 int64_t fAnchorStart;
1808 int64_t fAnchorLimit;
1814 int64_t fActiveStart;
1815 int64_t fActiveLimit;
1819 UBool fTransparentBounds;
1820 UBool fAnchoringBounds;
1823 int64_t fMatchStart;
1827 int64_t fLastMatchEnd;
1829 int64_t fAppendPosition;
1838 REStackFrame *fFrame;
1843 int64_t fSmallData[8];
1849 int32_t fTickCounter;
1854 int32_t fStackLimit;
1859 const void *fCallbackContext;
1863 const void *fFindProgressCallbackContext;
1866 UBool fInputUniStrMaybeMutable;
1878 #endif // UCONFIG_NO_REGULAR_EXPRESSIONS
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...
#define U_FINAL
Defined to the C++11 "final" keyword if available.
struct UHashtable UHashtable
virtual int32_t split(const UnicodeString &input, UnicodeString dest[], int32_t destCapacity, UErrorCode &status) const
Split a string into fields.
virtual UnicodeString replaceAll(const UnicodeString &replacement, UErrorCode &status)
Replaces every substring of the input that matches the pattern with the given replacement string.
The BreakIterator class implements methods for finding the location of boundaries in text.
virtual UnicodeString group(UErrorCode &status) const
Returns a string containing the text matched by the previous match.
UBool URegexMatchCallback(const void *context, int32_t steps)
Function pointer for a regular expression matching callback function.
C API: Parse Error Information.
class RegexMatcher bundles together a regular expression pattern and input text to which the expressi...
virtual UBool hasAnchoringBounds() const
Return true if this matcher is using anchoring bounds.
UBool operator==(const RegexPattern &that) const
Comparison operator.
virtual RegexMatcher & reset(const UnicodeString &input)
Resets this matcher with a new input string.
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...
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...
Basic definitions for ICU, for both C and C++ APIs.
virtual RegexMatcher & region(int64_t start, int64_t limit, UErrorCode &status)
Sets the limits of this matcher's region.
A mutable set of Unicode characters and multicharacter strings.
RegexMatcher(const UnicodeString ®exp, const UnicodeString &input, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
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...
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
virtual void setStackLimit(int32_t limit, UErrorCode &status)
Set the amount of heap storage available for use by the match backtracking stack.
int8_t UBool
The ICU boolean type.
virtual int32_t groupNumberFromName(const UnicodeString &groupName, UErrorCode &status) const
Get the group number corresponding to a named capture group.
virtual const UnicodeString & input() const
Returns the input string being matched.
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...
virtual int32_t split(UText *input, UText *dest[], int32_t destCapacity, UErrorCode &status)
Split a string into fields.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
static RegexPattern * compile(const UnicodeString ®ex, UParseError &pe, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object.
C API: Abstract Unicode Text API.
virtual UBool matches(UErrorCode &status)
Attempts to match the entire input region against the pattern.
virtual UText * inputText() const
Returns the input string being matched.
virtual void getMatchCallback(URegexMatchCallback *&callback, const void *&context, UErrorCode &status)
Get the callback function for this URegularExpression.
virtual ~RegexMatcher()
Destructor.
virtual UBool hitEnd() const
Return TRUE if the most recent matching operation attempted to access additional input beyond the ava...
virtual UBool hasTransparentBounds() const
Queries the transparency of region bounds for this matcher.
virtual UText * patternText(UErrorCode &status) const
Returns the regular expression from which this pattern was compiled.
A UParseError struct is used to returned detailed information about parsing errors.
virtual int32_t regionEnd() const
Reports the end (limit) index (exclusive) of this matcher's region.
virtual int32_t groupNumberFromName(const char *groupName, int32_t nameLength, UErrorCode &status) const
Get the group number corresponding to a named capture group.
virtual RegexMatcher & refreshInputText(UText *input, UErrorCode &status)
Set the subject text string upon which the regular expression is looking for matches without changing...
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...
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
RegexMatcher(UText *regexp, UText *input, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
virtual RegexMatcher & reset(int64_t index, UErrorCode &status)
Resets this matcher, and set the current input position.
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
UObject is the common ICU "boilerplate" class.
virtual UBool requireEnd() const
Return TRUE the most recent match succeeded and additional input could cause it to fail.
virtual int64_t regionEnd64() const
Reports the end (limit) index (exclusive) of this matcher's region.
virtual RegexPattern * clone() const
Create an exact copy of this RegexPattern object.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
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...
virtual UText * replaceFirst(UText *replacement, UText *dest, UErrorCode &status)
Replaces the first substring of the input that matches the pattern with the replacement string.
virtual UBool find(UErrorCode &status)
Find the next pattern match in the input string.
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...
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.
virtual UnicodeString & appendTail(UnicodeString &dest)
As the final step in a find-and-replace operation, append the remainder of the input string,...
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...
void setTrace(UBool state)
setTrace Debug function, enable/disable tracing of the matching engine.
RegexPattern()
default constructor.
RegexPattern(const RegexPattern &source)
Copy Constructor.
UBool operator!=(const RegexPattern &that) const
Comparison operator.
virtual int64_t regionStart64() const
Reports the start index of this matcher's region.
virtual UBool find()
Find the next pattern match in the input string.
virtual UText * replaceAll(UText *replacement, UText *dest, UErrorCode &status)
Replaces every substring of the input that matches the pattern with the given replacement string.
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...
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
C API: Regular Expressions.
virtual void setMatchCallback(URegexMatchCallback *callback, const void *context, UErrorCode &status)
Set a callback function for use with this Matcher.
virtual UBool matches(int64_t startIndex, UErrorCode &status)
Resets the matcher, then attempts to match the input beginning at the specified startIndex,...
virtual int32_t groupCount() const
Returns the number of capturing groups in this matcher's pattern.
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.
static UBool matches(UText *regex, UText *input, UParseError &pe, UErrorCode &status)
Test whether a string matches a regular expression.
virtual void getFindProgressCallback(URegexFindProgressCallback *&callback, const void *&context, UErrorCode &status)
Get the find progress callback function for this URegularExpression.
virtual RegexMatcher & useTransparentBounds(UBool b)
Sets the transparency of region bounds for this matcher.
void resetPreserveRegion()
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...
virtual UText * appendTail(UText *dest, UErrorCode &status)
As the final step in a find-and-replace operation, append the remainder of the input string,...
static RegexPattern * compile(const UnicodeString ®ex, uint32_t flags, UParseError &pe, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object using the specified URegexp...
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
RegexMatcher(UText *regexp, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
virtual UBool lookingAt(UErrorCode &status)
Attempts to match the input string, starting from the beginning of the region, against the pattern.
RegexMatcher(const UnicodeString ®exp, uint32_t flags, UErrorCode &status)
Construct a RegexMatcher for a regular expression.
virtual UBool lookingAt(int64_t startIndex, UErrorCode &status)
Attempts to match the input string, starting from the specified index, against the pattern.
virtual const RegexPattern & pattern() const
Returns the pattern that is interpreted by this matcher.
virtual UnicodeString replaceFirst(const UnicodeString &replacement, UErrorCode &status)
Replaces the first substring of the input that matches the pattern with the replacement string.
virtual void setTimeLimit(int32_t limit, UErrorCode &status)
Set a processing time limit for match operations with this Matcher.
virtual RegexMatcher * matcher(UErrorCode &status) const
Creates a RegexMatcher that will match against this pattern.
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...
static UBool matches(const UnicodeString ®ex, const UnicodeString &input, UParseError &pe, UErrorCode &status)
Test whether a string matches a regular expression.
Class RegexPattern represents a compiled regular expression.
virtual RegexMatcher & useAnchoringBounds(UBool b)
Set whether this matcher is using Anchoring Bounds for its region.
void dumpPattern() const
Dump a compiled pattern.
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...
virtual int32_t split(const UnicodeString &input, UnicodeString dest[], int32_t destCapacity, UErrorCode &status)
Split a string into fields.
virtual int32_t getStackLimit() const
Get the size of the heap storage available for use by the back tracking stack.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
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.
virtual ~RegexPattern()
Destructor.
C++ API: Common ICU base class UObject.
static RegexPattern * compile(UText *regex, UParseError &pe, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object.
virtual void setFindProgressCallback(URegexFindProgressCallback *callback, const void *context, UErrorCode &status)
Set a progress callback function for use with find operations on this Matcher.
virtual RegexMatcher & reset()
Resets this matcher.
virtual UnicodeString pattern() const
Returns the regular expression from which this pattern was compiled.
virtual int32_t getTimeLimit() const
Get the time limit, if any, for match operations made with this Matcher.
UBool URegexFindProgressCallback(const void *context, int64_t matchIndex)
Function pointer for a regular expression find callback function.
virtual int32_t regionStart() const
Reports the start index of this matcher's region.
virtual int32_t split(UText *input, UText *dest[], int32_t destCapacity, UErrorCode &status) const
Split a string into fields.
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...
virtual RegexMatcher * matcher(const UnicodeString &input, UErrorCode &status) const
Creates a RegexMatcher that will match the given input against this pattern.
virtual uint32_t flags() const
Get the URegexpFlag match mode flags that were used when compiling this pattern.
virtual RegexMatcher & reset(UText *input)
Resets this matcher with a new input string.
static RegexPattern * compile(const UnicodeString ®ex, uint32_t flags, UErrorCode &status)
Compiles the regular expression in string form into a RegexPattern object using the specified URegexp...
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 ...