jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ********************************************************************** jpayne@69: * Copyright (C) 2004-2016, International Business Machines jpayne@69: * Corporation and others. All Rights Reserved. jpayne@69: ********************************************************************** jpayne@69: * file name: uregex.h jpayne@69: * encoding: UTF-8 jpayne@69: * indentation:4 jpayne@69: * jpayne@69: * created on: 2004mar09 jpayne@69: * created by: Andy Heninger jpayne@69: * jpayne@69: * ICU Regular Expressions, API for C jpayne@69: */ jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C API: Regular Expressions jpayne@69: * jpayne@69: *
This is a C wrapper around the C++ RegexPattern and RegexMatcher classes.
jpayne@69: */ jpayne@69: jpayne@69: #ifndef UREGEX_H jpayne@69: #define UREGEX_H jpayne@69: jpayne@69: #include "unicode/utext.h" jpayne@69: #include "unicode/utypes.h" jpayne@69: jpayne@69: #if !UCONFIG_NO_REGULAR_EXPRESSIONS jpayne@69: jpayne@69: #include "unicode/localpointer.h" jpayne@69: #include "unicode/parseerr.h" jpayne@69: jpayne@69: struct URegularExpression; jpayne@69: /** jpayne@69: * Structure representing a compiled regular expression, plus the results jpayne@69: * of a match operation. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: typedef struct URegularExpression URegularExpression; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Constants for Regular Expression Match Modes. jpayne@69: * @stable ICU 2.4 jpayne@69: */ jpayne@69: typedef enum URegexpFlag{ jpayne@69: jpayne@69: #ifndef U_HIDE_DRAFT_API jpayne@69: /** Forces normalization of pattern and strings. jpayne@69: Not implemented yet, just a placeholder, hence draft. jpayne@69: @draft ICU 2.4 */ jpayne@69: UREGEX_CANON_EQ = 128, jpayne@69: #endif /* U_HIDE_DRAFT_API */ jpayne@69: /** Enable case insensitive matching. @stable ICU 2.4 */ jpayne@69: UREGEX_CASE_INSENSITIVE = 2, jpayne@69: jpayne@69: /** Allow white space and comments within patterns @stable ICU 2.4 */ jpayne@69: UREGEX_COMMENTS = 4, jpayne@69: jpayne@69: /** If set, '.' matches line terminators, otherwise '.' matching stops at line end. jpayne@69: * @stable ICU 2.4 */ jpayne@69: UREGEX_DOTALL = 32, jpayne@69: jpayne@69: /** If set, treat the entire pattern as a literal string. jpayne@69: * Metacharacters or escape sequences in the input sequence will be given jpayne@69: * no special meaning. jpayne@69: * jpayne@69: * The flag UREGEX_CASE_INSENSITIVE retains its impact jpayne@69: * on matching when used in conjunction with this flag. jpayne@69: * The other flags become superfluous. jpayne@69: * jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: UREGEX_LITERAL = 16, jpayne@69: jpayne@69: /** Control behavior of "$" and "^" jpayne@69: * If set, recognize line terminators within string, jpayne@69: * otherwise, match only at start and end of input string. jpayne@69: * @stable ICU 2.4 */ jpayne@69: UREGEX_MULTILINE = 8, jpayne@69: jpayne@69: /** Unix-only line endings. jpayne@69: * When this mode is enabled, only \\u000a is recognized as a line ending jpayne@69: * in the behavior of ., ^, and $. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: UREGEX_UNIX_LINES = 1, jpayne@69: jpayne@69: /** Unicode word boundaries. jpayne@69: * If set, \b uses the Unicode TR 29 definition of word boundaries. jpayne@69: * Warning: Unicode word boundaries are quite different from jpayne@69: * traditional regular expression word boundaries. See jpayne@69: * http://unicode.org/reports/tr29/#Word_Boundaries jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: UREGEX_UWORD = 256, jpayne@69: jpayne@69: /** Error on Unrecognized backslash escapes. jpayne@69: * If set, fail with an error on patterns that contain jpayne@69: * backslash-escaped ASCII letters without a known special jpayne@69: * meaning. If this flag is not set, these jpayne@69: * escaped letters represent themselves. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: UREGEX_ERROR_ON_UNKNOWN_ESCAPES = 512 jpayne@69: jpayne@69: } URegexpFlag; jpayne@69: jpayne@69: /** jpayne@69: * Open (compile) an ICU regular expression. Compiles the regular expression in jpayne@69: * string form into an internal representation using the specified match mode flags. jpayne@69: * The resulting regular expression handle can then be used to perform various jpayne@69: * matching operations. jpayne@69: * jpayne@69: * jpayne@69: * @param pattern The Regular Expression pattern to be compiled. jpayne@69: * @param patternLength The length of the pattern, or -1 if the pattern is jpayne@69: * NUL terminated. jpayne@69: * @param flags Flags that alter the default matching behavior for jpayne@69: * the regular expression, UREGEX_CASE_INSENSITIVE, for jpayne@69: * example. For default behavior, set this parameter to zero. jpayne@69: * Seeenum URegexpFlag
. All desired flags
jpayne@69: * are bitwise-ORed together.
jpayne@69: * @param pe Receives the position (line and column numbers) of any syntax
jpayne@69: * error within the source regular expression string. If this
jpayne@69: * information is not wanted, pass NULL for this parameter.
jpayne@69: * @param status Receives error detected by this function.
jpayne@69: * @stable ICU 3.0
jpayne@69: *
jpayne@69: */
jpayne@69: U_STABLE URegularExpression * U_EXPORT2
jpayne@69: uregex_open( const UChar *pattern,
jpayne@69: int32_t patternLength,
jpayne@69: uint32_t flags,
jpayne@69: UParseError *pe,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Open (compile) an ICU regular expression. Compiles the regular expression in
jpayne@69: * string form into an internal representation using the specified match mode flags.
jpayne@69: * The resulting regular expression handle can then be used to perform various
jpayne@69: * matching operations.
jpayne@69: *
jpayne@69: * The contents of the pattern UText will be extracted and saved. Ownership of the
jpayne@69: * UText struct itself remains with the caller. This is to match the behavior of
jpayne@69: * uregex_open().
jpayne@69: *
jpayne@69: * @param pattern The Regular Expression pattern to be compiled.
jpayne@69: * @param flags Flags that alter the default matching behavior for
jpayne@69: * the regular expression, UREGEX_CASE_INSENSITIVE, for
jpayne@69: * example. For default behavior, set this parameter to zero.
jpayne@69: * See enum URegexpFlag
. All desired flags
jpayne@69: * are bitwise-ORed together.
jpayne@69: * @param pe Receives the position (line and column numbers) of any syntax
jpayne@69: * error within the source regular expression string. If this
jpayne@69: * information is not wanted, pass NULL for this parameter.
jpayne@69: * @param status Receives error detected by this function.
jpayne@69: *
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE URegularExpression * U_EXPORT2
jpayne@69: uregex_openUText(UText *pattern,
jpayne@69: uint32_t flags,
jpayne@69: UParseError *pe,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: #if !UCONFIG_NO_CONVERSION
jpayne@69: /**
jpayne@69: * Open (compile) an ICU regular expression. The resulting regular expression
jpayne@69: * handle can then be used to perform various matching operations.
jpayne@69: *
jpayne@69: * This function is the same as uregex_open, except that the pattern
jpayne@69: * is supplied as an 8 bit char * string in the default code page.
jpayne@69: *
jpayne@69: * @param pattern The Regular Expression pattern to be compiled,
jpayne@69: * NUL terminated.
jpayne@69: * @param flags Flags that alter the default matching behavior for
jpayne@69: * the regular expression, UREGEX_CASE_INSENSITIVE, for
jpayne@69: * example. For default behavior, set this parameter to zero.
jpayne@69: * See enum URegexpFlag
. All desired flags
jpayne@69: * are bitwise-ORed together.
jpayne@69: * @param pe Receives the position (line and column numbers) of any syntax
jpayne@69: * error within the source regular expression string. If this
jpayne@69: * information is not wanted, pass NULL for this parameter.
jpayne@69: * @param status Receives errors detected by this function.
jpayne@69: * @return The URegularExpression object representing the compiled
jpayne@69: * pattern.
jpayne@69: *
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE URegularExpression * U_EXPORT2
jpayne@69: uregex_openC( const char *pattern,
jpayne@69: uint32_t flags,
jpayne@69: UParseError *pe,
jpayne@69: UErrorCode *status);
jpayne@69: #endif
jpayne@69:
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Close the regular expression, recovering all resources (memory) it
jpayne@69: * was holding.
jpayne@69: *
jpayne@69: * @param regexp The regular expression to be closed.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uregex_close(URegularExpression *regexp);
jpayne@69:
jpayne@69: #if U_SHOW_CPLUSPLUS_API
jpayne@69:
jpayne@69: U_NAMESPACE_BEGIN
jpayne@69:
jpayne@69: /**
jpayne@69: * \class LocalURegularExpressionPointer
jpayne@69: * "Smart pointer" class, closes a URegularExpression via uregex_close().
jpayne@69: * For most methods see the LocalPointerBase base class.
jpayne@69: *
jpayne@69: * @see LocalPointerBase
jpayne@69: * @see LocalPointer
jpayne@69: * @stable ICU 4.4
jpayne@69: */
jpayne@69: U_DEFINE_LOCAL_OPEN_POINTER(LocalURegularExpressionPointer, URegularExpression, uregex_close);
jpayne@69:
jpayne@69: U_NAMESPACE_END
jpayne@69:
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * Make a copy of a compiled regular expression. Cloning a regular
jpayne@69: * expression is faster than opening a second instance from the source
jpayne@69: * form of the expression, and requires less memory.
jpayne@69: *
jpayne@69: * Note that the current input string and the position of any matched text jpayne@69: * within it are not cloned; only the pattern itself and the jpayne@69: * match mode flags are copied. jpayne@69: *
jpayne@69: * Cloning can be particularly useful to threaded applications that perform jpayne@69: * multiple match operations in parallel. Each concurrent RE jpayne@69: * operation requires its own instance of a URegularExpression. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression to be cloned. jpayne@69: * @param status Receives indication of any errors encountered jpayne@69: * @return the cloned copy of the compiled regular expression. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: U_STABLE URegularExpression * U_EXPORT2 jpayne@69: uregex_clone(const URegularExpression *regexp, UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Returns a pointer to the source form of the pattern for this regular expression. jpayne@69: * This function will work even if the pattern was originally specified as a UText. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param patLength This output parameter will be set to the length of the jpayne@69: * pattern string. A NULL pointer may be used here if the jpayne@69: * pattern length is not needed, as would be the case if jpayne@69: * the pattern is known in advance to be a NUL terminated jpayne@69: * string. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * @return a pointer to the pattern string. The storage for the string is jpayne@69: * owned by the regular expression object, and must not be jpayne@69: * altered or deleted by the application. The returned string jpayne@69: * will remain valid until the regular expression is closed. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: U_STABLE const UChar * U_EXPORT2 jpayne@69: uregex_pattern(const URegularExpression *regexp, jpayne@69: int32_t *patLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Returns the source text of the pattern for this regular expression. jpayne@69: * This function will work even if the pattern was originally specified as a UChar string. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * @return the pattern text. The storage for the text is owned by the regular expression jpayne@69: * object, and must not be altered or deleted. jpayne@69: * jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE UText * U_EXPORT2 jpayne@69: uregex_patternUText(const URegularExpression *regexp, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Get the match mode flags that were specified when compiling this regular expression. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @return The match mode flags jpayne@69: * @see URegexpFlag jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uregex_flags(const URegularExpression *regexp, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Set the subject text string upon which the regular expression will look for matches. jpayne@69: * This function may be called any number of times, allowing the regular jpayne@69: * expression pattern to be applied to different strings. jpayne@69: *
jpayne@69: * Regular expression matching operations work directly on the application's jpayne@69: * string data. No copy is made. The subject string data must not be jpayne@69: * altered after calling this function until after all regular expression jpayne@69: * operations involving this string data are completed. jpayne@69: *
jpayne@69: * Zero length strings are permitted. In this case, no subsequent match jpayne@69: * operation will dereference the text string pointer. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param text The subject text string. jpayne@69: * @param textLength The length of the subject text, or -1 if the string jpayne@69: * is NUL terminated. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_setText(URegularExpression *regexp, jpayne@69: const UChar *text, jpayne@69: int32_t textLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Set the subject text string upon which the regular expression will look for matches. jpayne@69: * This function may be called any number of times, allowing the regular jpayne@69: * expression pattern to be applied to different strings. jpayne@69: *
jpayne@69: * Regular expression matching operations work directly on the application's jpayne@69: * string data; only a shallow clone is made. The subject string data must not be jpayne@69: * altered after calling this function until after all regular expression jpayne@69: * operations involving this string data are completed. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param text The subject text string. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_setUText(URegularExpression *regexp, jpayne@69: UText *text, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Get the subject text that is currently associated with this jpayne@69: * regular expression object. If the input was supplied using uregex_setText(), jpayne@69: * that pointer will be returned. Otherwise, the characters in the input will jpayne@69: * be extracted to a buffer and returned. In either case, ownership remains jpayne@69: * with the regular expression object. jpayne@69: * jpayne@69: * This function will work even if the input was originally specified as a UText. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param textLength The length of the string is returned in this output parameter. jpayne@69: * A NULL pointer may be used here if the jpayne@69: * text length is not needed, as would be the case if jpayne@69: * the text is known in advance to be a NUL terminated jpayne@69: * string. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * @return Pointer to the subject text string currently associated with jpayne@69: * this regular expression. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: U_STABLE const UChar * U_EXPORT2 jpayne@69: uregex_getText(URegularExpression *regexp, jpayne@69: int32_t *textLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Get the subject text that is currently associated with this jpayne@69: * regular expression object. jpayne@69: * jpayne@69: * This function will work even if the input was originally specified as a UChar string. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param dest A mutable UText in which to store the current input. jpayne@69: * If NULL, a new UText will be created as an immutable shallow clone jpayne@69: * of the actual input string. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * @return The subject text currently associated with this regular expression. jpayne@69: * If a pre-allocated UText was provided, it will always be used and returned. jpayne@69: * jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE UText * U_EXPORT2 jpayne@69: uregex_getUText(URegularExpression *regexp, jpayne@69: UText *dest, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Set the subject text string upon which the regular expression is looking for matches jpayne@69: * without changing any other aspect of the matching state. jpayne@69: * The new and previous text strings must have the same content. jpayne@69: * jpayne@69: * This function is intended for use in environments where ICU is operating on jpayne@69: * strings that may move around in memory. It provides a mechanism for notifying jpayne@69: * ICU that the string has been relocated, and providing a new UText to access the jpayne@69: * string in its new position. jpayne@69: * jpayne@69: * Note that the regular expression implementation never copies the underlying text jpayne@69: * of a string being matched, but always operates directly on the original text jpayne@69: * provided by the user. Refreshing simply drops the references to the old text jpayne@69: * and replaces them with references to the new. jpayne@69: * jpayne@69: * Caution: this function is normally used only by very specialized jpayne@69: * system-level code. One example use case is with garbage collection jpayne@69: * that moves the text in memory. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param text The new (moved) text string. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * jpayne@69: * @stable ICU 4.8 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_refreshUText(URegularExpression *regexp, jpayne@69: UText *text, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Attempts to match the input string against the pattern. jpayne@69: * To succeed, the match must extend to the end of the string, jpayne@69: * or cover the complete match region. jpayne@69: * jpayne@69: * If startIndex >= zero the match operation starts at the specified jpayne@69: * index and must extend to the end of the input string. Any region jpayne@69: * that has been specified is reset. jpayne@69: * jpayne@69: * If startIndex == -1 the match must cover the input region, or the entire jpayne@69: * input string if no region has been set. This directly corresponds to jpayne@69: * Matcher.matches() in Java jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param startIndex The input string (native) index at which to begin matching, or -1 jpayne@69: * to match the input Region. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * @return TRUE if there is a match jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: U_STABLE UBool U_EXPORT2 jpayne@69: uregex_matches(URegularExpression *regexp, jpayne@69: int32_t startIndex, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * 64bit version of uregex_matches. jpayne@69: * Attempts to match the input string against the pattern. jpayne@69: * To succeed, the match must extend to the end of the string, jpayne@69: * or cover the complete match region. jpayne@69: * jpayne@69: * If startIndex >= zero the match operation starts at the specified jpayne@69: * index and must extend to the end of the input string. Any region jpayne@69: * that has been specified is reset. jpayne@69: * jpayne@69: * If startIndex == -1 the match must cover the input region, or the entire jpayne@69: * input string if no region has been set. This directly corresponds to jpayne@69: * Matcher.matches() in Java jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param startIndex The input string (native) index at which to begin matching, or -1 jpayne@69: * to match the input Region. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * @return TRUE if there is a match jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE UBool U_EXPORT2 jpayne@69: uregex_matches64(URegularExpression *regexp, jpayne@69: int64_t startIndex, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Attempts to match the input string, starting from the specified index, against the pattern. jpayne@69: * The match may be of any length, and is not required to extend to the end jpayne@69: * of the input string. Contrast with uregex_matches(). jpayne@69: * jpayne@69: *
If startIndex is >= 0 any input region that was set for this jpayne@69: * URegularExpression is reset before the operation begins. jpayne@69: * jpayne@69: *
If the specified starting index == -1 the match begins at the start of the input jpayne@69: * region, or at the start of the full string if no region has been specified. jpayne@69: * This corresponds directly with Matcher.lookingAt() in Java. jpayne@69: * jpayne@69: *
If the match succeeds then more information can be obtained via the
jpayne@69: * uregexp_start()
, uregexp_end()
,
jpayne@69: * and uregex_group()
functions.
If startIndex is >= 0 any input region that was set for this jpayne@69: * URegularExpression is reset before the operation begins. jpayne@69: * jpayne@69: *
If the specified starting index == -1 the match begins at the start of the input jpayne@69: * region, or at the start of the full string if no region has been specified. jpayne@69: * This corresponds directly with Matcher.lookingAt() in Java. jpayne@69: * jpayne@69: *
If the match succeeds then more information can be obtained via the
jpayne@69: * uregexp_start()
, uregexp_end()
,
jpayne@69: * and uregex_group()
functions.
uregex_start(), uregex_end()
, and
jpayne@69: * uregex_group()
will provide more information regarding the match.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param startIndex The position (native) in the input string to begin the search, or
jpayne@69: * -1 to search within the Input Region.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return TRUE if a match is found.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uregex_find(URegularExpression *regexp,
jpayne@69: int32_t startIndex,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * 64bit version of uregex_find.
jpayne@69: * Find the first matching substring of the input string that matches the pattern.
jpayne@69: * If startIndex is >= zero the search for a match begins at the specified index,
jpayne@69: * and any match region is reset. This corresponds directly with
jpayne@69: * Matcher.find(startIndex) in Java.
jpayne@69: *
jpayne@69: * If startIndex == -1 the search begins at the start of the input region,
jpayne@69: * or at the start of the full string if no region has been specified.
jpayne@69: *
jpayne@69: * If a match is found, uregex_start(), uregex_end()
, and
jpayne@69: * uregex_group()
will provide more information regarding the match.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param startIndex The position (native) in the input string to begin the search, or
jpayne@69: * -1 to search within the Input Region.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return TRUE if a match is found.
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uregex_find64(URegularExpression *regexp,
jpayne@69: int64_t startIndex,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Find the next pattern match in the input string. Begin searching
jpayne@69: * the input at the location following the end of he previous match,
jpayne@69: * or at the start of the string (or region) if there is no
jpayne@69: * previous match. If a match is found, uregex_start(), uregex_end()
, and
jpayne@69: * uregex_group()
will provide more information regarding the match.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return TRUE if a match is found.
jpayne@69: * @see uregex_reset
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uregex_findNext(URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Get the number of capturing groups in this regular expression's pattern.
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return the number of capture groups
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_groupCount(URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Get the group number corresponding to a named capture group.
jpayne@69: * The returned number can be used with any function that access
jpayne@69: * capture groups by number.
jpayne@69: *
jpayne@69: * The function returns an error status if the specified name does not
jpayne@69: * appear in the pattern.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param groupName The capture group name.
jpayne@69: * @param nameLength The length of the name, or -1 if the name is a
jpayne@69: * nul-terminated string.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: *
jpayne@69: * @stable ICU 55
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_groupNumberFromName(URegularExpression *regexp,
jpayne@69: const UChar *groupName,
jpayne@69: int32_t nameLength,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Get the group number corresponding to a named capture group.
jpayne@69: * The returned number can be used with any function that access
jpayne@69: * capture groups by number.
jpayne@69: *
jpayne@69: * The function returns an error status if the specified name does not
jpayne@69: * appear in the pattern.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param groupName The capture group name,
jpayne@69: * platform invariant characters only.
jpayne@69: * @param nameLength The length of the name, or -1 if the name is
jpayne@69: * nul-terminated.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: *
jpayne@69: * @stable ICU 55
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_groupNumberFromCName(URegularExpression *regexp,
jpayne@69: const char *groupName,
jpayne@69: int32_t nameLength,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /** Extract the string for the specified matching expression or subexpression.
jpayne@69: * Group #0 is the complete string of matched text.
jpayne@69: * Group #1 is the text matched by the first set of capturing parentheses.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param groupNum The capture group to extract. Group 0 is the complete
jpayne@69: * match. The value of this parameter must be
jpayne@69: * less than or equal to the number of capture groups in
jpayne@69: * the pattern.
jpayne@69: * @param dest Buffer to receive the matching string data
jpayne@69: * @param destCapacity Capacity of the dest buffer.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return Length of matching data,
jpayne@69: * or -1 if no applicable match.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_group(URegularExpression *regexp,
jpayne@69: int32_t groupNum,
jpayne@69: UChar *dest,
jpayne@69: int32_t destCapacity,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /** Returns a shallow immutable clone of the entire input string with the current index set
jpayne@69: * to the beginning of the requested capture group. The capture group length is also
jpayne@69: * returned via groupLength.
jpayne@69: * Group #0 is the complete string of matched text.
jpayne@69: * Group #1 is the text matched by the first set of capturing parentheses.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param groupNum The capture group to extract. Group 0 is the complete
jpayne@69: * match. The value of this parameter must be
jpayne@69: * less than or equal to the number of capture groups in
jpayne@69: * the pattern.
jpayne@69: * @param dest A mutable UText in which to store the current input.
jpayne@69: * If NULL, a new UText will be created as an immutable shallow clone
jpayne@69: * of the entire input string.
jpayne@69: * @param groupLength The group length of the desired capture group. Output parameter.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return The subject text currently associated with this regular expression.
jpayne@69: * If a pre-allocated UText was provided, it will always be used and returned.
jpayne@69:
jpayne@69: *
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE UText * U_EXPORT2
jpayne@69: uregex_groupUText(URegularExpression *regexp,
jpayne@69: int32_t groupNum,
jpayne@69: UText *dest,
jpayne@69: int64_t *groupLength,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the index in the input string of the start of the text matched by the
jpayne@69: * specified capture group during the previous match operation. Return -1 if
jpayne@69: * the capture group was not part of the last match.
jpayne@69: * Group #0 refers to the complete range of matched text.
jpayne@69: * Group #1 refers to the text matched by the first set of capturing parentheses.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param groupNum The capture group number
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return the starting (native) position in the input of the text matched
jpayne@69: * by the specified group.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_start(URegularExpression *regexp,
jpayne@69: int32_t groupNum,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * 64bit version of uregex_start.
jpayne@69: * Returns the index in the input string of the start of the text matched by the
jpayne@69: * specified capture group during the previous match operation. Return -1 if
jpayne@69: * the capture group was not part of the last match.
jpayne@69: * Group #0 refers to the complete range of matched text.
jpayne@69: * Group #1 refers to the text matched by the first set of capturing parentheses.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param groupNum The capture group number
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return the starting (native) position in the input of the text matched
jpayne@69: * by the specified group.
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE int64_t U_EXPORT2
jpayne@69: uregex_start64(URegularExpression *regexp,
jpayne@69: int32_t groupNum,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns the index in the input string of the position following the end
jpayne@69: * of the text matched by the specified capture group.
jpayne@69: * Return -1 if the capture group was not part of the last match.
jpayne@69: * Group #0 refers to the complete range of matched text.
jpayne@69: * Group #1 refers to the text matched by the first set of capturing parentheses.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param groupNum The capture group number
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return the (native) index of the position following the last matched character.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_end(URegularExpression *regexp,
jpayne@69: int32_t groupNum,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * 64bit version of uregex_end.
jpayne@69: * Returns the index in the input string of the position following the end
jpayne@69: * of the text matched by the specified capture group.
jpayne@69: * Return -1 if the capture group was not part of the last match.
jpayne@69: * Group #0 refers to the complete range of matched text.
jpayne@69: * Group #1 refers to the text matched by the first set of capturing parentheses.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param groupNum The capture group number
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return the (native) index of the position following the last matched character.
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE int64_t U_EXPORT2
jpayne@69: uregex_end64(URegularExpression *regexp,
jpayne@69: int32_t groupNum,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Reset any saved state from the previous match. Has the effect of
jpayne@69: * causing uregex_findNext to begin at the specified index, and causing
jpayne@69: * uregex_start(), uregex_end() and uregex_group() to return an error
jpayne@69: * indicating that there is no match information available. Clears any
jpayne@69: * match region that may have been set.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param index The position (native) in the text at which a
jpayne@69: * uregex_findNext() should begin searching.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uregex_reset(URegularExpression *regexp,
jpayne@69: int32_t index,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * 64bit version of uregex_reset.
jpayne@69: * Reset any saved state from the previous match. Has the effect of
jpayne@69: * causing uregex_findNext to begin at the specified index, and causing
jpayne@69: * uregex_start(), uregex_end() and uregex_group() to return an error
jpayne@69: * indicating that there is no match information available. Clears any
jpayne@69: * match region that may have been set.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param index The position (native) in the text at which a
jpayne@69: * uregex_findNext() should begin searching.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uregex_reset64(URegularExpression *regexp,
jpayne@69: int64_t index,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets the limits of the matching region for this URegularExpression.
jpayne@69: * The region is the part of the input string that will be considered when matching.
jpayne@69: * Invoking this method resets any saved state from the previous match,
jpayne@69: * then sets the region to start at the index specified by the start parameter
jpayne@69: * and end at the index specified by the end parameter.
jpayne@69: *
jpayne@69: * Depending on the transparency and anchoring being used (see useTransparentBounds
jpayne@69: * and useAnchoringBounds), certain constructs such as anchors may behave differently
jpayne@69: * at or around the boundaries of the region
jpayne@69: *
jpayne@69: * The function will fail if start is greater than limit, or if either index
jpayne@69: * is less than zero or greater than the length of the string being matched.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param regionStart The (native) index to begin searches at.
jpayne@69: * @param regionLimit The (native) index to end searches at (exclusive).
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uregex_setRegion(URegularExpression *regexp,
jpayne@69: int32_t regionStart,
jpayne@69: int32_t regionLimit,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * 64bit version of uregex_setRegion.
jpayne@69: * Sets the limits of the matching region for this URegularExpression.
jpayne@69: * The region is the part of the input string that will be considered when matching.
jpayne@69: * Invoking this method resets any saved state from the previous match,
jpayne@69: * then sets the region to start at the index specified by the start parameter
jpayne@69: * and end at the index specified by the end parameter.
jpayne@69: *
jpayne@69: * Depending on the transparency and anchoring being used (see useTransparentBounds
jpayne@69: * and useAnchoringBounds), certain constructs such as anchors may behave differently
jpayne@69: * at or around the boundaries of the region
jpayne@69: *
jpayne@69: * The function will fail if start is greater than limit, or if either index
jpayne@69: * is less than zero or greater than the length of the string being matched.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param regionStart The (native) index to begin searches at.
jpayne@69: * @param regionLimit The (native) index to end searches at (exclusive).
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uregex_setRegion64(URegularExpression *regexp,
jpayne@69: int64_t regionStart,
jpayne@69: int64_t regionLimit,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Set the matching region and the starting index for subsequent matches
jpayne@69: * in a single operation.
jpayne@69: * This is useful because the usual function for setting the starting
jpayne@69: * index, urgex_reset(), also resets any region limits.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param regionStart The (native) index to begin searches at.
jpayne@69: * @param regionLimit The (native) index to end searches at (exclusive).
jpayne@69: * @param startIndex The index in the input text at which the next
jpayne@69: * match operation should begin.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uregex_setRegionAndStart(URegularExpression *regexp,
jpayne@69: int64_t regionStart,
jpayne@69: int64_t regionLimit,
jpayne@69: int64_t startIndex,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Reports the start index of the matching region. Any matches found are limited to
jpayne@69: * to the region bounded by regionStart (inclusive) and regionEnd (exclusive).
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @return The starting (native) index of this matcher's region.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_regionStart(const URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * 64bit version of uregex_regionStart.
jpayne@69: * Reports the start index of the matching region. Any matches found are limited to
jpayne@69: * to the region bounded by regionStart (inclusive) and regionEnd (exclusive).
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @return The starting (native) index of this matcher's region.
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE int64_t U_EXPORT2
jpayne@69: uregex_regionStart64(const URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Reports the end index (exclusive) of the matching region for this URegularExpression.
jpayne@69: * Any matches found are limited to to the region bounded by regionStart (inclusive)
jpayne@69: * and regionEnd (exclusive).
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @return The ending point (native) of this matcher's region.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_regionEnd(const URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * 64bit version of uregex_regionEnd.
jpayne@69: * Reports the end index (exclusive) of the matching region for this URegularExpression.
jpayne@69: * Any matches found are limited to to the region bounded by regionStart (inclusive)
jpayne@69: * and regionEnd (exclusive).
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @return The ending point (native) of this matcher's region.
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE int64_t U_EXPORT2
jpayne@69: uregex_regionEnd64(const URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Queries the transparency of region bounds for this URegularExpression.
jpayne@69: * See useTransparentBounds for a description of transparent and opaque bounds.
jpayne@69: * By default, matching boundaries are opaque.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @return TRUE if this matcher is using opaque bounds, false if it is not.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uregex_hasTransparentBounds(const URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets the transparency of region bounds for this URegularExpression.
jpayne@69: * Invoking this function with an argument of TRUE will set matches to use transparent bounds.
jpayne@69: * If the boolean argument is FALSE, then opaque bounds will be used.
jpayne@69: *
jpayne@69: * Using transparent bounds, the boundaries of the matching region are transparent
jpayne@69: * to lookahead, lookbehind, and boundary matching constructs. Those constructs can
jpayne@69: * see text beyond the boundaries of the region while checking for a match.
jpayne@69: *
jpayne@69: * With opaque bounds, no text outside of the matching region is visible to lookahead,
jpayne@69: * lookbehind, and boundary matching constructs.
jpayne@69: *
jpayne@69: * By default, opaque bounds are used.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param b TRUE for transparent bounds; FALSE for opaque bounds
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @stable ICU 4.0
jpayne@69: **/
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uregex_useTransparentBounds(URegularExpression *regexp,
jpayne@69: UBool b,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Return true if this URegularExpression is using anchoring bounds.
jpayne@69: * By default, anchoring region bounds are used.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @return TRUE if this matcher is using anchoring bounds.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uregex_hasAnchoringBounds(const URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Set whether this URegularExpression is using Anchoring Bounds for its region.
jpayne@69: * With anchoring bounds, pattern anchors such as ^ and $ will match at the start
jpayne@69: * and end of the region. Without Anchoring Bounds, anchors will only match at
jpayne@69: * the positions they would in the complete text.
jpayne@69: *
jpayne@69: * Anchoring Bounds are the default for regions.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param b TRUE if to enable anchoring bounds; FALSE to disable them.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uregex_useAnchoringBounds(URegularExpression *regexp,
jpayne@69: UBool b,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Return TRUE if the most recent matching operation touched the
jpayne@69: * end of the text being processed. In this case, additional input text could
jpayne@69: * change the results of that match.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @return TRUE if the most recent match hit the end of input
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uregex_hitEnd(const URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Return TRUE the most recent match succeeded and additional input could cause
jpayne@69: * it to fail. If this function returns false and a match was found, then more input
jpayne@69: * might change the match but the match won't be lost. If a match was not found,
jpayne@69: * then requireEnd has no meaning.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param status A pointer to a UErrorCode to receive any errors.
jpayne@69: * @return TRUE if more input could cause the most recent match to no longer match.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uregex_requireEnd(const URegularExpression *regexp,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69:
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Replaces every substring of the input that matches the pattern
jpayne@69: * with the given replacement string. This is a convenience function that
jpayne@69: * provides a complete find-and-replace-all operation.
jpayne@69: *
jpayne@69: * This method scans the input string looking for matches of the pattern.
jpayne@69: * Input that is not part of any match is copied unchanged to the
jpayne@69: * destination buffer. Matched regions are replaced in the output
jpayne@69: * buffer by the replacement string. The replacement string may contain
jpayne@69: * references to capture groups; these take the form of $1, $2, etc.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param replacementText A string containing the replacement text.
jpayne@69: * @param replacementLength The length of the replacement string, or
jpayne@69: * -1 if it is NUL terminated.
jpayne@69: * @param destBuf A (UChar *) buffer that will receive the result.
jpayne@69: * @param destCapacity The capacity of the destination buffer.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return The length of the string resulting from the find
jpayne@69: * and replace operation. In the event that the
jpayne@69: * destination capacity is inadequate, the return value
jpayne@69: * is still the full length of the untruncated string.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_replaceAll(URegularExpression *regexp,
jpayne@69: const UChar *replacementText,
jpayne@69: int32_t replacementLength,
jpayne@69: UChar *destBuf,
jpayne@69: int32_t destCapacity,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Replaces every substring of the input that matches the pattern
jpayne@69: * with the given replacement string. This is a convenience function that
jpayne@69: * provides a complete find-and-replace-all operation.
jpayne@69: *
jpayne@69: * This method scans the input string looking for matches of the pattern.
jpayne@69: * Input that is not part of any match is copied unchanged to the
jpayne@69: * destination buffer. Matched regions are replaced in the output
jpayne@69: * buffer by the replacement string. The replacement string may contain
jpayne@69: * references to capture groups; these take the form of $1, $2, etc.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param replacement A string containing the replacement text.
jpayne@69: * @param dest A mutable UText that will receive the result.
jpayne@69: * If NULL, a new UText will be created (which may not be mutable).
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return A UText containing the results of the find and replace.
jpayne@69: * If a pre-allocated UText was provided, it will always be used and returned.
jpayne@69: *
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE UText * U_EXPORT2
jpayne@69: uregex_replaceAllUText(URegularExpression *regexp,
jpayne@69: UText *replacement,
jpayne@69: UText *dest,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Replaces the first substring of the input that matches the pattern
jpayne@69: * with the given replacement string. This is a convenience function that
jpayne@69: * provides a complete find-and-replace operation.
jpayne@69: *
jpayne@69: * This method scans the input string looking for a match of the pattern.
jpayne@69: * All input that is not part of the match is copied unchanged to the
jpayne@69: * destination buffer. The matched region is replaced in the output
jpayne@69: * buffer by the replacement string. The replacement string may contain
jpayne@69: * references to capture groups; these take the form of $1, $2, etc.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param replacementText A string containing the replacement text.
jpayne@69: * @param replacementLength The length of the replacement string, or
jpayne@69: * -1 if it is NUL terminated.
jpayne@69: * @param destBuf A (UChar *) buffer that will receive the result.
jpayne@69: * @param destCapacity The capacity of the destination buffer.
jpayne@69: * @param status a reference to a UErrorCode to receive any errors.
jpayne@69: * @return The length of the string resulting from the find
jpayne@69: * and replace operation. In the event that the
jpayne@69: * destination capacity is inadequate, the return value
jpayne@69: * is still the full length of the untruncated string.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_replaceFirst(URegularExpression *regexp,
jpayne@69: const UChar *replacementText,
jpayne@69: int32_t replacementLength,
jpayne@69: UChar *destBuf,
jpayne@69: int32_t destCapacity,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Replaces the first substring of the input that matches the pattern
jpayne@69: * with the given replacement string. This is a convenience function that
jpayne@69: * provides a complete find-and-replace operation.
jpayne@69: *
jpayne@69: * This method scans the input string looking for a match of the pattern.
jpayne@69: * All input that is not part of the match is copied unchanged to the
jpayne@69: * destination buffer. The matched region is replaced in the output
jpayne@69: * buffer by the replacement string. The replacement string may contain
jpayne@69: * references to capture groups; these take the form of $1, $2, etc.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param replacement A string containing the replacement text.
jpayne@69: * @param dest A mutable UText that will receive the result.
jpayne@69: * If NULL, a new UText will be created (which may not be mutable).
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return A UText containing the results of the find and replace.
jpayne@69: * If a pre-allocated UText was provided, it will always be used and returned.
jpayne@69: *
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE UText * U_EXPORT2
jpayne@69: uregex_replaceFirstUText(URegularExpression *regexp,
jpayne@69: UText *replacement,
jpayne@69: UText *dest,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Implements a replace operation intended to be used as part of an
jpayne@69: * incremental find-and-replace.
jpayne@69: *
jpayne@69: * The input string, starting from the end of the previous match and ending at jpayne@69: * the start of the current match, is appended to the destination string. Then the jpayne@69: * replacement string is appended to the output string, jpayne@69: * including handling any substitutions of captured text.
jpayne@69: * jpayne@69: *A note on preflight computation of buffersize and error handling: jpayne@69: * Calls to uregex_appendReplacement() and uregex_appendTail() are jpayne@69: * designed to be chained, one after another, with the destination jpayne@69: * buffer pointer and buffer capacity updated after each in preparation jpayne@69: * to for the next. If the destination buffer is exhausted partway through such a jpayne@69: * sequence, a U_BUFFER_OVERFLOW_ERROR status will be returned. Normal jpayne@69: * ICU conventions are for a function to perform no action if it is jpayne@69: * called with an error status, but for this one case, uregex_appendRepacement() jpayne@69: * will operate normally so that buffer size computations will complete jpayne@69: * correctly. jpayne@69: * jpayne@69: *
For simple, prepackaged, non-incremental find-and-replace jpayne@69: * operations, see replaceFirst() or replaceAll().
jpayne@69: * jpayne@69: * @param regexp The regular expression object. jpayne@69: * @param replacementText The string that will replace the matched portion of the jpayne@69: * input string as it is copied to the destination buffer. jpayne@69: * The replacement text may contain references ($1, for jpayne@69: * example) to capture groups from the match. jpayne@69: * @param replacementLength The length of the replacement text string, jpayne@69: * or -1 if the string is NUL terminated. jpayne@69: * @param destBuf The buffer into which the results of the jpayne@69: * find-and-replace are placed. On return, this pointer jpayne@69: * will be updated to refer to the beginning of the jpayne@69: * unused portion of buffer, leaving it in position for jpayne@69: * a subsequent call to this function. jpayne@69: * @param destCapacity The size of the output buffer, On return, this jpayne@69: * parameter will be updated to reflect the space remaining jpayne@69: * unused in the output buffer. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * @return The length of the result string. In the event that jpayne@69: * destCapacity is inadequate, the full length of the jpayne@69: * untruncated output string is returned. jpayne@69: * jpayne@69: * @stable ICU 3.0 jpayne@69: * jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uregex_appendReplacement(URegularExpression *regexp, jpayne@69: const UChar *replacementText, jpayne@69: int32_t replacementLength, jpayne@69: UChar **destBuf, jpayne@69: int32_t *destCapacity, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Implements a replace operation intended to be used as part of an jpayne@69: * incremental find-and-replace. jpayne@69: * jpayne@69: *The input string, starting from the end of the previous match and ending at jpayne@69: * the start of the current match, is appended to the destination string. Then the jpayne@69: * replacement string is appended to the output string, jpayne@69: * including handling any substitutions of captured text.
jpayne@69: * jpayne@69: *For simple, prepackaged, non-incremental find-and-replace jpayne@69: * operations, see replaceFirst() or replaceAll().
jpayne@69: * jpayne@69: * @param regexp The regular expression object. jpayne@69: * @param replacementText The string that will replace the matched portion of the jpayne@69: * input string as it is copied to the destination buffer. jpayne@69: * The replacement text may contain references ($1, for jpayne@69: * example) to capture groups from the match. jpayne@69: * @param dest A mutable UText that will receive the result. Must not be NULL. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_appendReplacementUText(URegularExpression *regexp, jpayne@69: UText *replacementText, jpayne@69: UText *dest, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * As the final step in a find-and-replace operation, append the remainder jpayne@69: * of the input string, starting at the position following the last match, jpayne@69: * to the destination string.uregex_appendTail()
is intended
jpayne@69: * to be invoked after one or more invocations of the
jpayne@69: * uregex_appendReplacement()
function.
jpayne@69: *
jpayne@69: * @param regexp The regular expression object. This is needed to
jpayne@69: * obtain the input string and with the position
jpayne@69: * of the last match within it.
jpayne@69: * @param destBuf The buffer in which the results of the
jpayne@69: * find-and-replace are placed. On return, the pointer
jpayne@69: * will be updated to refer to the beginning of the
jpayne@69: * unused portion of buffer.
jpayne@69: * @param destCapacity The size of the output buffer, On return, this
jpayne@69: * value will be updated to reflect the space remaining
jpayne@69: * unused in the output buffer.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return The length of the result string. In the event that
jpayne@69: * destCapacity is inadequate, the full length of the
jpayne@69: * untruncated output string is returned.
jpayne@69: *
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_appendTail(URegularExpression *regexp,
jpayne@69: UChar **destBuf,
jpayne@69: int32_t *destCapacity,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * As the final step in a find-and-replace operation, append the remainder
jpayne@69: * of the input string, starting at the position following the last match,
jpayne@69: * to the destination string. uregex_appendTailUText()
is intended
jpayne@69: * to be invoked after one or more invocations of the
jpayne@69: * uregex_appendReplacementUText()
function.
jpayne@69: *
jpayne@69: * @param regexp The regular expression object. This is needed to
jpayne@69: * obtain the input string and with the position
jpayne@69: * of the last match within it.
jpayne@69: * @param dest A mutable UText that will receive the result. Must not be NULL.
jpayne@69: *
jpayne@69: * @param status Error code
jpayne@69: *
jpayne@69: * @return The destination UText.
jpayne@69: *
jpayne@69: * @stable ICU 4.6
jpayne@69: */
jpayne@69: U_STABLE UText * U_EXPORT2
jpayne@69: uregex_appendTailUText(URegularExpression *regexp,
jpayne@69: UText *dest,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Split a string into fields. Somewhat like split() from Perl.
jpayne@69: * The pattern matches identify delimiters that separate the input
jpayne@69: * into fields. The input data between the matches becomes the
jpayne@69: * fields themselves.
jpayne@69: *
jpayne@69: * Each of the fields is copied from the input string to the destination
jpayne@69: * buffer, and NUL terminated. The position of each field within
jpayne@69: * the destination buffer is returned in the destFields array.
jpayne@69: *
jpayne@69: * If the delimiter pattern includes capture groups, the captured text will
jpayne@69: * also appear in the destination array of output strings, interspersed
jpayne@69: * with the fields. This is similar to Perl, but differs from Java,
jpayne@69: * which ignores the presence of capture groups in the pattern.
jpayne@69: *
jpayne@69: * Trailing empty fields will always be returned, assuming sufficient
jpayne@69: * destination capacity. This differs from the default behavior for Java
jpayne@69: * and Perl where trailing empty fields are not returned.
jpayne@69: *
jpayne@69: * The number of strings produced by the split operation is returned.
jpayne@69: * This count includes the strings from capture groups in the delimiter pattern.
jpayne@69: * This behavior differs from Java, which ignores capture groups.
jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression.
jpayne@69: * @param destBuf A (UChar *) buffer to receive the fields that
jpayne@69: * are extracted from the input string. These
jpayne@69: * field pointers will refer to positions within the
jpayne@69: * destination buffer supplied by the caller. Any
jpayne@69: * extra positions within the destFields array will be
jpayne@69: * set to NULL.
jpayne@69: * @param destCapacity The capacity of the destBuf.
jpayne@69: * @param requiredCapacity The actual capacity required of the destBuf.
jpayne@69: * If destCapacity is too small, requiredCapacity will return
jpayne@69: * the total capacity required to hold all of the output, and
jpayne@69: * a U_BUFFER_OVERFLOW_ERROR will be returned.
jpayne@69: * @param destFields An array to be filled with the position of each
jpayne@69: * of the extracted fields within destBuf.
jpayne@69: * @param destFieldsCapacity The number of elements in the destFields array.
jpayne@69: * If the number of fields found is less than destFieldsCapacity,
jpayne@69: * the extra destFields elements are set to zero.
jpayne@69: * If destFieldsCapacity is too small, the trailing part of the
jpayne@69: * input, including any field delimiters, is treated as if it
jpayne@69: * were the last field - it is copied to the destBuf, and
jpayne@69: * its position is in the destBuf is stored in the last element
jpayne@69: * of destFields. This behavior mimics that of Perl. It is not
jpayne@69: * an error condition, and no error status is returned when all destField
jpayne@69: * positions are used.
jpayne@69: * @param status A reference to a UErrorCode to receive any errors.
jpayne@69: * @return The number of fields into which the input string was split.
jpayne@69: * @stable ICU 3.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uregex_split( URegularExpression *regexp,
jpayne@69: UChar *destBuf,
jpayne@69: int32_t destCapacity,
jpayne@69: int32_t *requiredCapacity,
jpayne@69: UChar *destFields[],
jpayne@69: int32_t destFieldsCapacity,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Split a string into fields. Somewhat like split() from Perl.
jpayne@69: * The pattern matches identify delimiters that separate the input
jpayne@69: * into fields. The input data between the matches becomes the
jpayne@69: * fields themselves.
jpayne@69: * jpayne@69: * The behavior of this function is not very closely aligned with uregex_split(); jpayne@69: * instead, it is based on (and implemented directly on top of) the C++ split method. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param destFields An array of mutable UText structs to receive the results of the split. jpayne@69: * If a field is NULL, a new UText is allocated to contain the results for jpayne@69: * that field. This new UText is not guaranteed to be mutable. jpayne@69: * @param destFieldsCapacity The number of elements in the destination array. jpayne@69: * If the number of fields found is less than destCapacity, the jpayne@69: * extra strings in the destination array are not altered. jpayne@69: * If the number of destination strings is less than the number jpayne@69: * of fields, the trailing part of the input string, including any jpayne@69: * field delimiters, is placed in the last destination string. jpayne@69: * This behavior mimics that of Perl. It is not an error condition, and no jpayne@69: * error status is returned when all destField positions are used. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * @return The number of fields into which the input string was split. jpayne@69: * jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uregex_splitUText(URegularExpression *regexp, jpayne@69: UText *destFields[], jpayne@69: int32_t destFieldsCapacity, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Set a processing time limit for match operations with this URegularExpression. jpayne@69: * jpayne@69: * Some patterns, when matching certain strings, can run in exponential time. jpayne@69: * For practical purposes, the match operation may appear to be in an jpayne@69: * infinite loop. jpayne@69: * When a limit is set a match operation will fail with an error if the jpayne@69: * limit is exceeded. jpayne@69: *
jpayne@69: * The units of the limit are steps of the match engine. jpayne@69: * Correspondence with actual processor time will depend on the speed jpayne@69: * of the processor and the details of the specific pattern, but will jpayne@69: * typically be on the order of milliseconds. jpayne@69: *
jpayne@69: * By default, the matching time is not limited. jpayne@69: *
jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param limit The limit value, or 0 for no limit. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_setTimeLimit(URegularExpression *regexp, jpayne@69: int32_t limit, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Get the time limit for for matches with this URegularExpression. jpayne@69: * A return value of zero indicates that there is no limit. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * @return the maximum allowed time for a match, in units of processing steps. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uregex_getTimeLimit(const URegularExpression *regexp, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Set the amount of heap storage available for use by the match backtracking stack. jpayne@69: *
jpayne@69: * ICU uses a backtracking regular expression engine, with the backtrack stack jpayne@69: * maintained on the heap. This function sets the limit to the amount of memory jpayne@69: * that can be used for this purpose. A backtracking stack overflow will jpayne@69: * result in an error from the match operation that caused it. jpayne@69: *
jpayne@69: * A limit is desirable because a malicious or poorly designed pattern can use jpayne@69: * excessive memory, potentially crashing the process. A limit is enabled jpayne@69: * by default. jpayne@69: *
jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param limit The maximum size, in bytes, of the matching backtrack stack. jpayne@69: * A value of zero means no limit. jpayne@69: * The limit must be greater than or equal to zero. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_setStackLimit(URegularExpression *regexp, jpayne@69: int32_t limit, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Get the size of the heap storage available for use by the back tracking stack. jpayne@69: * jpayne@69: * @return the maximum backtracking stack size, in bytes, or zero if the jpayne@69: * stack size is unlimited. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uregex_getStackLimit(const URegularExpression *regexp, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Function pointer for a regular expression matching callback function. jpayne@69: * When set, a callback function will be called periodically during matching jpayne@69: * operations. If the call back function returns FALSE, the matching jpayne@69: * operation will be terminated early. jpayne@69: * jpayne@69: * Note: the callback function must not call other functions on this jpayne@69: * URegularExpression. jpayne@69: * jpayne@69: * @param context context pointer. The callback function will be invoked jpayne@69: * with the context specified at the time that jpayne@69: * uregex_setMatchCallback() is called. jpayne@69: * @param steps the accumulated processing time, in match steps, jpayne@69: * for this matching operation. jpayne@69: * @return TRUE to continue the matching operation. jpayne@69: * FALSE to terminate the matching operation. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: U_CDECL_BEGIN jpayne@69: typedef UBool U_CALLCONV URegexMatchCallback ( jpayne@69: const void *context, jpayne@69: int32_t steps); jpayne@69: U_CDECL_END jpayne@69: jpayne@69: /** jpayne@69: * Set a callback function for this URegularExpression. jpayne@69: * During matching operations the function will be called periodically, jpayne@69: * giving the application the opportunity to terminate a long-running jpayne@69: * match. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param callback A pointer to the user-supplied callback function. jpayne@69: * @param context User context pointer. The value supplied at the jpayne@69: * time the callback function is set will be saved jpayne@69: * and passed to the callback each time that it is called. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_setMatchCallback(URegularExpression *regexp, jpayne@69: URegexMatchCallback *callback, jpayne@69: const void *context, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Get the callback function for this URegularExpression. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param callback Out parameter, receives a pointer to the user-supplied jpayne@69: * callback function. jpayne@69: * @param context Out parameter, receives the user context pointer that jpayne@69: * was set when uregex_setMatchCallback() was called. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_getMatchCallback(const URegularExpression *regexp, jpayne@69: URegexMatchCallback **callback, jpayne@69: const void **context, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Function pointer for a regular expression find callback function. jpayne@69: * jpayne@69: * When set, a callback function will be called during a find operation jpayne@69: * and for operations that depend on find, such as findNext, split and some replace jpayne@69: * operations like replaceFirst. jpayne@69: * The callback will usually be called after each attempt at a match, but this is not a jpayne@69: * guarantee that the callback will be invoked at each character. For finds where the jpayne@69: * match engine is invoked at each character, this may be close to true, but less likely jpayne@69: * for more optimized loops where the pattern is known to only start, and the match jpayne@69: * engine invoked, at certain characters. jpayne@69: * When invoked, this callback will specify the index at which a match operation is about jpayne@69: * to be attempted, giving the application the opportunity to terminate a long-running jpayne@69: * find operation. jpayne@69: * jpayne@69: * If the call back function returns FALSE, the find operation will be terminated early. jpayne@69: * jpayne@69: * Note: the callback function must not call other functions on this jpayne@69: * URegularExpression jpayne@69: * jpayne@69: * @param context context pointer. The callback function will be invoked jpayne@69: * with the context specified at the time that jpayne@69: * uregex_setFindProgressCallback() is called. jpayne@69: * @param matchIndex the next index at which a match attempt will be attempted for this jpayne@69: * find operation. If this callback interrupts the search, this is the jpayne@69: * index at which a find/findNext operation may be re-initiated. jpayne@69: * @return TRUE to continue the matching operation. jpayne@69: * FALSE to terminate the matching operation. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_CDECL_BEGIN jpayne@69: typedef UBool U_CALLCONV URegexFindProgressCallback ( jpayne@69: const void *context, jpayne@69: int64_t matchIndex); jpayne@69: U_CDECL_END jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Set the find progress callback function for this URegularExpression. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param callback A pointer to the user-supplied callback function. jpayne@69: * @param context User context pointer. The value supplied at the jpayne@69: * time the callback function is set will be saved jpayne@69: * and passed to the callback each time that it is called. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_setFindProgressCallback(URegularExpression *regexp, jpayne@69: URegexFindProgressCallback *callback, jpayne@69: const void *context, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Get the find progress callback function for this URegularExpression. jpayne@69: * jpayne@69: * @param regexp The compiled regular expression. jpayne@69: * @param callback Out parameter, receives a pointer to the user-supplied jpayne@69: * callback function. jpayne@69: * @param context Out parameter, receives the user context pointer that jpayne@69: * was set when uregex_setFindProgressCallback() was called. jpayne@69: * @param status A reference to a UErrorCode to receive any errors. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uregex_getFindProgressCallback(const URegularExpression *regexp, jpayne@69: URegexFindProgressCallback **callback, jpayne@69: const void **context, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ jpayne@69: #endif /* UREGEX_H */