1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ********************************************************************** 5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2004-2016, International Business Machines 6*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ********************************************************************** 8*0e209d39SAndroid Build Coastguard Worker * file name: uregex.h 9*0e209d39SAndroid Build Coastguard Worker * encoding: UTF-8 10*0e209d39SAndroid Build Coastguard Worker * indentation:4 11*0e209d39SAndroid Build Coastguard Worker * 12*0e209d39SAndroid Build Coastguard Worker * created on: 2004mar09 13*0e209d39SAndroid Build Coastguard Worker * created by: Andy Heninger 14*0e209d39SAndroid Build Coastguard Worker * 15*0e209d39SAndroid Build Coastguard Worker * ICU Regular Expressions, API for C 16*0e209d39SAndroid Build Coastguard Worker */ 17*0e209d39SAndroid Build Coastguard Worker 18*0e209d39SAndroid Build Coastguard Worker /** 19*0e209d39SAndroid Build Coastguard Worker * \file 20*0e209d39SAndroid Build Coastguard Worker * \brief C API: Regular Expressions 21*0e209d39SAndroid Build Coastguard Worker * 22*0e209d39SAndroid Build Coastguard Worker * <p>This is a C wrapper around the C++ RegexPattern and RegexMatcher classes.</p> 23*0e209d39SAndroid Build Coastguard Worker */ 24*0e209d39SAndroid Build Coastguard Worker 25*0e209d39SAndroid Build Coastguard Worker #ifndef UREGEX_H 26*0e209d39SAndroid Build Coastguard Worker #define UREGEX_H 27*0e209d39SAndroid Build Coastguard Worker 28*0e209d39SAndroid Build Coastguard Worker #include "unicode/utext.h" 29*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 30*0e209d39SAndroid Build Coastguard Worker 31*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_REGULAR_EXPRESSIONS 32*0e209d39SAndroid Build Coastguard Worker 33*0e209d39SAndroid Build Coastguard Worker #include "unicode/parseerr.h" 34*0e209d39SAndroid Build Coastguard Worker 35*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 36*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h" 37*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API 38*0e209d39SAndroid Build Coastguard Worker 39*0e209d39SAndroid Build Coastguard Worker struct URegularExpression; 40*0e209d39SAndroid Build Coastguard Worker /** 41*0e209d39SAndroid Build Coastguard Worker * Structure representing a compiled regular expression, plus the results 42*0e209d39SAndroid Build Coastguard Worker * of a match operation. 43*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 44*0e209d39SAndroid Build Coastguard Worker */ 45*0e209d39SAndroid Build Coastguard Worker typedef struct URegularExpression URegularExpression; 46*0e209d39SAndroid Build Coastguard Worker 47*0e209d39SAndroid Build Coastguard Worker 48*0e209d39SAndroid Build Coastguard Worker /** 49*0e209d39SAndroid Build Coastguard Worker * Constants for Regular Expression Match Modes. 50*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.4 51*0e209d39SAndroid Build Coastguard Worker */ 52*0e209d39SAndroid Build Coastguard Worker typedef enum URegexpFlag{ 53*0e209d39SAndroid Build Coastguard Worker 54*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DRAFT_API 55*0e209d39SAndroid Build Coastguard Worker /** Forces normalization of pattern and strings. 56*0e209d39SAndroid Build Coastguard Worker Not implemented yet, just a placeholder, hence draft. 57*0e209d39SAndroid Build Coastguard Worker @draft ICU 2.4 */ 58*0e209d39SAndroid Build Coastguard Worker UREGEX_CANON_EQ = 128, 59*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DRAFT_API */ 60*0e209d39SAndroid Build Coastguard Worker /** Enable case insensitive matching. @stable ICU 2.4 */ 61*0e209d39SAndroid Build Coastguard Worker UREGEX_CASE_INSENSITIVE = 2, 62*0e209d39SAndroid Build Coastguard Worker 63*0e209d39SAndroid Build Coastguard Worker /** Allow white space and comments within patterns @stable ICU 2.4 */ 64*0e209d39SAndroid Build Coastguard Worker UREGEX_COMMENTS = 4, 65*0e209d39SAndroid Build Coastguard Worker 66*0e209d39SAndroid Build Coastguard Worker /** If set, '.' matches line terminators, otherwise '.' matching stops at line end. 67*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.4 */ 68*0e209d39SAndroid Build Coastguard Worker UREGEX_DOTALL = 32, 69*0e209d39SAndroid Build Coastguard Worker 70*0e209d39SAndroid Build Coastguard Worker /** If set, treat the entire pattern as a literal string. 71*0e209d39SAndroid Build Coastguard Worker * Metacharacters or escape sequences in the input sequence will be given 72*0e209d39SAndroid Build Coastguard Worker * no special meaning. 73*0e209d39SAndroid Build Coastguard Worker * 74*0e209d39SAndroid Build Coastguard Worker * The flag UREGEX_CASE_INSENSITIVE retains its impact 75*0e209d39SAndroid Build Coastguard Worker * on matching when used in conjunction with this flag. 76*0e209d39SAndroid Build Coastguard Worker * The other flags become superfluous. 77*0e209d39SAndroid Build Coastguard Worker * 78*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 79*0e209d39SAndroid Build Coastguard Worker */ 80*0e209d39SAndroid Build Coastguard Worker UREGEX_LITERAL = 16, 81*0e209d39SAndroid Build Coastguard Worker 82*0e209d39SAndroid Build Coastguard Worker /** Control behavior of "$" and "^" 83*0e209d39SAndroid Build Coastguard Worker * If set, recognize line terminators within string, 84*0e209d39SAndroid Build Coastguard Worker * otherwise, match only at start and end of input string. 85*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.4 */ 86*0e209d39SAndroid Build Coastguard Worker UREGEX_MULTILINE = 8, 87*0e209d39SAndroid Build Coastguard Worker 88*0e209d39SAndroid Build Coastguard Worker /** Unix-only line endings. 89*0e209d39SAndroid Build Coastguard Worker * When this mode is enabled, only \\u000a is recognized as a line ending 90*0e209d39SAndroid Build Coastguard Worker * in the behavior of ., ^, and $. 91*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 92*0e209d39SAndroid Build Coastguard Worker */ 93*0e209d39SAndroid Build Coastguard Worker UREGEX_UNIX_LINES = 1, 94*0e209d39SAndroid Build Coastguard Worker 95*0e209d39SAndroid Build Coastguard Worker /** Unicode word boundaries. 96*0e209d39SAndroid Build Coastguard Worker * If set, \b uses the Unicode TR 29 definition of word boundaries. 97*0e209d39SAndroid Build Coastguard Worker * Warning: Unicode word boundaries are quite different from 98*0e209d39SAndroid Build Coastguard Worker * traditional regular expression word boundaries. See 99*0e209d39SAndroid Build Coastguard Worker * http://unicode.org/reports/tr29/#Word_Boundaries 100*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.8 101*0e209d39SAndroid Build Coastguard Worker */ 102*0e209d39SAndroid Build Coastguard Worker UREGEX_UWORD = 256, 103*0e209d39SAndroid Build Coastguard Worker 104*0e209d39SAndroid Build Coastguard Worker /** Error on Unrecognized backslash escapes. 105*0e209d39SAndroid Build Coastguard Worker * If set, fail with an error on patterns that contain 106*0e209d39SAndroid Build Coastguard Worker * backslash-escaped ASCII letters without a known special 107*0e209d39SAndroid Build Coastguard Worker * meaning. If this flag is not set, these 108*0e209d39SAndroid Build Coastguard Worker * escaped letters represent themselves. 109*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 110*0e209d39SAndroid Build Coastguard Worker */ 111*0e209d39SAndroid Build Coastguard Worker UREGEX_ERROR_ON_UNKNOWN_ESCAPES = 512 112*0e209d39SAndroid Build Coastguard Worker 113*0e209d39SAndroid Build Coastguard Worker } URegexpFlag; 114*0e209d39SAndroid Build Coastguard Worker 115*0e209d39SAndroid Build Coastguard Worker /** 116*0e209d39SAndroid Build Coastguard Worker * Open (compile) an ICU regular expression. Compiles the regular expression in 117*0e209d39SAndroid Build Coastguard Worker * string form into an internal representation using the specified match mode flags. 118*0e209d39SAndroid Build Coastguard Worker * The resulting regular expression handle can then be used to perform various 119*0e209d39SAndroid Build Coastguard Worker * matching operations. 120*0e209d39SAndroid Build Coastguard Worker * 121*0e209d39SAndroid Build Coastguard Worker * 122*0e209d39SAndroid Build Coastguard Worker * @param pattern The Regular Expression pattern to be compiled. 123*0e209d39SAndroid Build Coastguard Worker * @param patternLength The length of the pattern, or -1 if the pattern is 124*0e209d39SAndroid Build Coastguard Worker * NUL terminated. 125*0e209d39SAndroid Build Coastguard Worker * @param flags Flags that alter the default matching behavior for 126*0e209d39SAndroid Build Coastguard Worker * the regular expression, UREGEX_CASE_INSENSITIVE, for 127*0e209d39SAndroid Build Coastguard Worker * example. For default behavior, set this parameter to zero. 128*0e209d39SAndroid Build Coastguard Worker * See <code>enum URegexpFlag</code>. All desired flags 129*0e209d39SAndroid Build Coastguard Worker * are bitwise-ORed together. 130*0e209d39SAndroid Build Coastguard Worker * @param pe Receives the position (line and column numbers) of any syntax 131*0e209d39SAndroid Build Coastguard Worker * error within the source regular expression string. If this 132*0e209d39SAndroid Build Coastguard Worker * information is not wanted, pass NULL for this parameter. 133*0e209d39SAndroid Build Coastguard Worker * @param status Receives error detected by this function. 134*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 135*0e209d39SAndroid Build Coastguard Worker * 136*0e209d39SAndroid Build Coastguard Worker */ 137*0e209d39SAndroid Build Coastguard Worker U_CAPI URegularExpression * U_EXPORT2 138*0e209d39SAndroid Build Coastguard Worker uregex_open( const UChar *pattern, 139*0e209d39SAndroid Build Coastguard Worker int32_t patternLength, 140*0e209d39SAndroid Build Coastguard Worker uint32_t flags, 141*0e209d39SAndroid Build Coastguard Worker UParseError *pe, 142*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 143*0e209d39SAndroid Build Coastguard Worker 144*0e209d39SAndroid Build Coastguard Worker /** 145*0e209d39SAndroid Build Coastguard Worker * Open (compile) an ICU regular expression. Compiles the regular expression in 146*0e209d39SAndroid Build Coastguard Worker * string form into an internal representation using the specified match mode flags. 147*0e209d39SAndroid Build Coastguard Worker * The resulting regular expression handle can then be used to perform various 148*0e209d39SAndroid Build Coastguard Worker * matching operations. 149*0e209d39SAndroid Build Coastguard Worker * <p> 150*0e209d39SAndroid Build Coastguard Worker * The contents of the pattern UText will be extracted and saved. Ownership of the 151*0e209d39SAndroid Build Coastguard Worker * UText struct itself remains with the caller. This is to match the behavior of 152*0e209d39SAndroid Build Coastguard Worker * uregex_open(). 153*0e209d39SAndroid Build Coastguard Worker * 154*0e209d39SAndroid Build Coastguard Worker * @param pattern The Regular Expression pattern to be compiled. 155*0e209d39SAndroid Build Coastguard Worker * @param flags Flags that alter the default matching behavior for 156*0e209d39SAndroid Build Coastguard Worker * the regular expression, UREGEX_CASE_INSENSITIVE, for 157*0e209d39SAndroid Build Coastguard Worker * example. For default behavior, set this parameter to zero. 158*0e209d39SAndroid Build Coastguard Worker * See <code>enum URegexpFlag</code>. All desired flags 159*0e209d39SAndroid Build Coastguard Worker * are bitwise-ORed together. 160*0e209d39SAndroid Build Coastguard Worker * @param pe Receives the position (line and column numbers) of any syntax 161*0e209d39SAndroid Build Coastguard Worker * error within the source regular expression string. If this 162*0e209d39SAndroid Build Coastguard Worker * information is not wanted, pass NULL for this parameter. 163*0e209d39SAndroid Build Coastguard Worker * @param status Receives error detected by this function. 164*0e209d39SAndroid Build Coastguard Worker * 165*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 166*0e209d39SAndroid Build Coastguard Worker */ 167*0e209d39SAndroid Build Coastguard Worker U_CAPI URegularExpression * U_EXPORT2 168*0e209d39SAndroid Build Coastguard Worker uregex_openUText(UText *pattern, 169*0e209d39SAndroid Build Coastguard Worker uint32_t flags, 170*0e209d39SAndroid Build Coastguard Worker UParseError *pe, 171*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 172*0e209d39SAndroid Build Coastguard Worker 173*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_CONVERSION 174*0e209d39SAndroid Build Coastguard Worker /** 175*0e209d39SAndroid Build Coastguard Worker * Open (compile) an ICU regular expression. The resulting regular expression 176*0e209d39SAndroid Build Coastguard Worker * handle can then be used to perform various matching operations. 177*0e209d39SAndroid Build Coastguard Worker * <p> 178*0e209d39SAndroid Build Coastguard Worker * This function is the same as uregex_open, except that the pattern 179*0e209d39SAndroid Build Coastguard Worker * is supplied as an 8 bit char * string in the default code page. 180*0e209d39SAndroid Build Coastguard Worker * 181*0e209d39SAndroid Build Coastguard Worker * @param pattern The Regular Expression pattern to be compiled, 182*0e209d39SAndroid Build Coastguard Worker * NUL terminated. 183*0e209d39SAndroid Build Coastguard Worker * @param flags Flags that alter the default matching behavior for 184*0e209d39SAndroid Build Coastguard Worker * the regular expression, UREGEX_CASE_INSENSITIVE, for 185*0e209d39SAndroid Build Coastguard Worker * example. For default behavior, set this parameter to zero. 186*0e209d39SAndroid Build Coastguard Worker * See <code>enum URegexpFlag</code>. All desired flags 187*0e209d39SAndroid Build Coastguard Worker * are bitwise-ORed together. 188*0e209d39SAndroid Build Coastguard Worker * @param pe Receives the position (line and column numbers) of any syntax 189*0e209d39SAndroid Build Coastguard Worker * error within the source regular expression string. If this 190*0e209d39SAndroid Build Coastguard Worker * information is not wanted, pass NULL for this parameter. 191*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 192*0e209d39SAndroid Build Coastguard Worker * @return The URegularExpression object representing the compiled 193*0e209d39SAndroid Build Coastguard Worker * pattern. 194*0e209d39SAndroid Build Coastguard Worker * 195*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 196*0e209d39SAndroid Build Coastguard Worker */ 197*0e209d39SAndroid Build Coastguard Worker U_CAPI URegularExpression * U_EXPORT2 198*0e209d39SAndroid Build Coastguard Worker uregex_openC( const char *pattern, 199*0e209d39SAndroid Build Coastguard Worker uint32_t flags, 200*0e209d39SAndroid Build Coastguard Worker UParseError *pe, 201*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 202*0e209d39SAndroid Build Coastguard Worker #endif 203*0e209d39SAndroid Build Coastguard Worker 204*0e209d39SAndroid Build Coastguard Worker 205*0e209d39SAndroid Build Coastguard Worker 206*0e209d39SAndroid Build Coastguard Worker /** 207*0e209d39SAndroid Build Coastguard Worker * Close the regular expression, recovering all resources (memory) it 208*0e209d39SAndroid Build Coastguard Worker * was holding. 209*0e209d39SAndroid Build Coastguard Worker * 210*0e209d39SAndroid Build Coastguard Worker * @param regexp The regular expression to be closed. 211*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 212*0e209d39SAndroid Build Coastguard Worker */ 213*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 214*0e209d39SAndroid Build Coastguard Worker uregex_close(URegularExpression *regexp); 215*0e209d39SAndroid Build Coastguard Worker 216*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 217*0e209d39SAndroid Build Coastguard Worker 218*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 219*0e209d39SAndroid Build Coastguard Worker 220*0e209d39SAndroid Build Coastguard Worker /** 221*0e209d39SAndroid Build Coastguard Worker * \class LocalURegularExpressionPointer 222*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class, closes a URegularExpression via uregex_close(). 223*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class. 224*0e209d39SAndroid Build Coastguard Worker * 225*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase 226*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer 227*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.4 228*0e209d39SAndroid Build Coastguard Worker */ 229*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalURegularExpressionPointer, URegularExpression, uregex_close); 230*0e209d39SAndroid Build Coastguard Worker 231*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 232*0e209d39SAndroid Build Coastguard Worker 233*0e209d39SAndroid Build Coastguard Worker #endif 234*0e209d39SAndroid Build Coastguard Worker 235*0e209d39SAndroid Build Coastguard Worker /** 236*0e209d39SAndroid Build Coastguard Worker * Make a copy of a compiled regular expression. Cloning a regular 237*0e209d39SAndroid Build Coastguard Worker * expression is faster than opening a second instance from the source 238*0e209d39SAndroid Build Coastguard Worker * form of the expression, and requires less memory. 239*0e209d39SAndroid Build Coastguard Worker * <p> 240*0e209d39SAndroid Build Coastguard Worker * Note that the current input string and the position of any matched text 241*0e209d39SAndroid Build Coastguard Worker * within it are not cloned; only the pattern itself and the 242*0e209d39SAndroid Build Coastguard Worker * match mode flags are copied. 243*0e209d39SAndroid Build Coastguard Worker * <p> 244*0e209d39SAndroid Build Coastguard Worker * Cloning can be particularly useful to threaded applications that perform 245*0e209d39SAndroid Build Coastguard Worker * multiple match operations in parallel. Each concurrent RE 246*0e209d39SAndroid Build Coastguard Worker * operation requires its own instance of a URegularExpression. 247*0e209d39SAndroid Build Coastguard Worker * 248*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression to be cloned. 249*0e209d39SAndroid Build Coastguard Worker * @param status Receives indication of any errors encountered 250*0e209d39SAndroid Build Coastguard Worker * @return the cloned copy of the compiled regular expression. 251*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 252*0e209d39SAndroid Build Coastguard Worker */ 253*0e209d39SAndroid Build Coastguard Worker U_CAPI URegularExpression * U_EXPORT2 254*0e209d39SAndroid Build Coastguard Worker uregex_clone(const URegularExpression *regexp, UErrorCode *status); 255*0e209d39SAndroid Build Coastguard Worker 256*0e209d39SAndroid Build Coastguard Worker /** 257*0e209d39SAndroid Build Coastguard Worker * Returns a pointer to the source form of the pattern for this regular expression. 258*0e209d39SAndroid Build Coastguard Worker * This function will work even if the pattern was originally specified as a UText. 259*0e209d39SAndroid Build Coastguard Worker * 260*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 261*0e209d39SAndroid Build Coastguard Worker * @param patLength This output parameter will be set to the length of the 262*0e209d39SAndroid Build Coastguard Worker * pattern string. A NULL pointer may be used here if the 263*0e209d39SAndroid Build Coastguard Worker * pattern length is not needed, as would be the case if 264*0e209d39SAndroid Build Coastguard Worker * the pattern is known in advance to be a NUL terminated 265*0e209d39SAndroid Build Coastguard Worker * string. 266*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 267*0e209d39SAndroid Build Coastguard Worker * @return a pointer to the pattern string. The storage for the string is 268*0e209d39SAndroid Build Coastguard Worker * owned by the regular expression object, and must not be 269*0e209d39SAndroid Build Coastguard Worker * altered or deleted by the application. The returned string 270*0e209d39SAndroid Build Coastguard Worker * will remain valid until the regular expression is closed. 271*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 272*0e209d39SAndroid Build Coastguard Worker */ 273*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar * U_EXPORT2 274*0e209d39SAndroid Build Coastguard Worker uregex_pattern(const URegularExpression *regexp, 275*0e209d39SAndroid Build Coastguard Worker int32_t *patLength, 276*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 277*0e209d39SAndroid Build Coastguard Worker 278*0e209d39SAndroid Build Coastguard Worker /** 279*0e209d39SAndroid Build Coastguard Worker * Returns the source text of the pattern for this regular expression. 280*0e209d39SAndroid Build Coastguard Worker * This function will work even if the pattern was originally specified as a UChar string. 281*0e209d39SAndroid Build Coastguard Worker * 282*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 283*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 284*0e209d39SAndroid Build Coastguard Worker * @return the pattern text. The storage for the text is owned by the regular expression 285*0e209d39SAndroid Build Coastguard Worker * object, and must not be altered or deleted. 286*0e209d39SAndroid Build Coastguard Worker * 287*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 288*0e209d39SAndroid Build Coastguard Worker */ 289*0e209d39SAndroid Build Coastguard Worker U_CAPI UText * U_EXPORT2 290*0e209d39SAndroid Build Coastguard Worker uregex_patternUText(const URegularExpression *regexp, 291*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 292*0e209d39SAndroid Build Coastguard Worker 293*0e209d39SAndroid Build Coastguard Worker /** 294*0e209d39SAndroid Build Coastguard Worker * Get the match mode flags that were specified when compiling this regular expression. 295*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 296*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 297*0e209d39SAndroid Build Coastguard Worker * @return The match mode flags 298*0e209d39SAndroid Build Coastguard Worker * @see URegexpFlag 299*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 300*0e209d39SAndroid Build Coastguard Worker */ 301*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 302*0e209d39SAndroid Build Coastguard Worker uregex_flags(const URegularExpression *regexp, 303*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 304*0e209d39SAndroid Build Coastguard Worker 305*0e209d39SAndroid Build Coastguard Worker 306*0e209d39SAndroid Build Coastguard Worker /** 307*0e209d39SAndroid Build Coastguard Worker * Set the subject text string upon which the regular expression will look for matches. 308*0e209d39SAndroid Build Coastguard Worker * This function may be called any number of times, allowing the regular 309*0e209d39SAndroid Build Coastguard Worker * expression pattern to be applied to different strings. 310*0e209d39SAndroid Build Coastguard Worker * <p> 311*0e209d39SAndroid Build Coastguard Worker * Regular expression matching operations work directly on the application's 312*0e209d39SAndroid Build Coastguard Worker * string data. No copy is made. The subject string data must not be 313*0e209d39SAndroid Build Coastguard Worker * altered after calling this function until after all regular expression 314*0e209d39SAndroid Build Coastguard Worker * operations involving this string data are completed. 315*0e209d39SAndroid Build Coastguard Worker * <p> 316*0e209d39SAndroid Build Coastguard Worker * Zero length strings are permitted. In this case, no subsequent match 317*0e209d39SAndroid Build Coastguard Worker * operation will dereference the text string pointer. 318*0e209d39SAndroid Build Coastguard Worker * 319*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 320*0e209d39SAndroid Build Coastguard Worker * @param text The subject text string. 321*0e209d39SAndroid Build Coastguard Worker * @param textLength The length of the subject text, or -1 if the string 322*0e209d39SAndroid Build Coastguard Worker * is NUL terminated. 323*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 324*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 325*0e209d39SAndroid Build Coastguard Worker */ 326*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 327*0e209d39SAndroid Build Coastguard Worker uregex_setText(URegularExpression *regexp, 328*0e209d39SAndroid Build Coastguard Worker const UChar *text, 329*0e209d39SAndroid Build Coastguard Worker int32_t textLength, 330*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 331*0e209d39SAndroid Build Coastguard Worker 332*0e209d39SAndroid Build Coastguard Worker 333*0e209d39SAndroid Build Coastguard Worker /** 334*0e209d39SAndroid Build Coastguard Worker * Set the subject text string upon which the regular expression will look for matches. 335*0e209d39SAndroid Build Coastguard Worker * This function may be called any number of times, allowing the regular 336*0e209d39SAndroid Build Coastguard Worker * expression pattern to be applied to different strings. 337*0e209d39SAndroid Build Coastguard Worker * <p> 338*0e209d39SAndroid Build Coastguard Worker * Regular expression matching operations work directly on the application's 339*0e209d39SAndroid Build Coastguard Worker * string data; only a shallow clone is made. The subject string data must not be 340*0e209d39SAndroid Build Coastguard Worker * altered after calling this function until after all regular expression 341*0e209d39SAndroid Build Coastguard Worker * operations involving this string data are completed. 342*0e209d39SAndroid Build Coastguard Worker * 343*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 344*0e209d39SAndroid Build Coastguard Worker * @param text The subject text string. 345*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 346*0e209d39SAndroid Build Coastguard Worker * 347*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 348*0e209d39SAndroid Build Coastguard Worker */ 349*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 350*0e209d39SAndroid Build Coastguard Worker uregex_setUText(URegularExpression *regexp, 351*0e209d39SAndroid Build Coastguard Worker UText *text, 352*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 353*0e209d39SAndroid Build Coastguard Worker 354*0e209d39SAndroid Build Coastguard Worker /** 355*0e209d39SAndroid Build Coastguard Worker * Get the subject text that is currently associated with this 356*0e209d39SAndroid Build Coastguard Worker * regular expression object. If the input was supplied using uregex_setText(), 357*0e209d39SAndroid Build Coastguard Worker * that pointer will be returned. Otherwise, the characters in the input will 358*0e209d39SAndroid Build Coastguard Worker * be extracted to a buffer and returned. In either case, ownership remains 359*0e209d39SAndroid Build Coastguard Worker * with the regular expression object. 360*0e209d39SAndroid Build Coastguard Worker * 361*0e209d39SAndroid Build Coastguard Worker * This function will work even if the input was originally specified as a UText. 362*0e209d39SAndroid Build Coastguard Worker * 363*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 364*0e209d39SAndroid Build Coastguard Worker * @param textLength The length of the string is returned in this output parameter. 365*0e209d39SAndroid Build Coastguard Worker * A NULL pointer may be used here if the 366*0e209d39SAndroid Build Coastguard Worker * text length is not needed, as would be the case if 367*0e209d39SAndroid Build Coastguard Worker * the text is known in advance to be a NUL terminated 368*0e209d39SAndroid Build Coastguard Worker * string. 369*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 370*0e209d39SAndroid Build Coastguard Worker * @return Pointer to the subject text string currently associated with 371*0e209d39SAndroid Build Coastguard Worker * this regular expression. 372*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 373*0e209d39SAndroid Build Coastguard Worker */ 374*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar * U_EXPORT2 375*0e209d39SAndroid Build Coastguard Worker uregex_getText(URegularExpression *regexp, 376*0e209d39SAndroid Build Coastguard Worker int32_t *textLength, 377*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 378*0e209d39SAndroid Build Coastguard Worker 379*0e209d39SAndroid Build Coastguard Worker /** 380*0e209d39SAndroid Build Coastguard Worker * Get the subject text that is currently associated with this 381*0e209d39SAndroid Build Coastguard Worker * regular expression object. 382*0e209d39SAndroid Build Coastguard Worker * 383*0e209d39SAndroid Build Coastguard Worker * This function will work even if the input was originally specified as a UChar string. 384*0e209d39SAndroid Build Coastguard Worker * 385*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 386*0e209d39SAndroid Build Coastguard Worker * @param dest A mutable UText in which to store the current input. 387*0e209d39SAndroid Build Coastguard Worker * If NULL, a new UText will be created as an immutable shallow clone 388*0e209d39SAndroid Build Coastguard Worker * of the actual input string. 389*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 390*0e209d39SAndroid Build Coastguard Worker * @return The subject text currently associated with this regular expression. 391*0e209d39SAndroid Build Coastguard Worker * If a pre-allocated UText was provided, it will always be used and returned. 392*0e209d39SAndroid Build Coastguard Worker * 393*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 394*0e209d39SAndroid Build Coastguard Worker */ 395*0e209d39SAndroid Build Coastguard Worker U_CAPI UText * U_EXPORT2 396*0e209d39SAndroid Build Coastguard Worker uregex_getUText(URegularExpression *regexp, 397*0e209d39SAndroid Build Coastguard Worker UText *dest, 398*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 399*0e209d39SAndroid Build Coastguard Worker 400*0e209d39SAndroid Build Coastguard Worker /** 401*0e209d39SAndroid Build Coastguard Worker * Set the subject text string upon which the regular expression is looking for matches 402*0e209d39SAndroid Build Coastguard Worker * without changing any other aspect of the matching state. 403*0e209d39SAndroid Build Coastguard Worker * The new and previous text strings must have the same content. 404*0e209d39SAndroid Build Coastguard Worker * 405*0e209d39SAndroid Build Coastguard Worker * This function is intended for use in environments where ICU is operating on 406*0e209d39SAndroid Build Coastguard Worker * strings that may move around in memory. It provides a mechanism for notifying 407*0e209d39SAndroid Build Coastguard Worker * ICU that the string has been relocated, and providing a new UText to access the 408*0e209d39SAndroid Build Coastguard Worker * string in its new position. 409*0e209d39SAndroid Build Coastguard Worker * 410*0e209d39SAndroid Build Coastguard Worker * Note that the regular expression implementation never copies the underlying text 411*0e209d39SAndroid Build Coastguard Worker * of a string being matched, but always operates directly on the original text 412*0e209d39SAndroid Build Coastguard Worker * provided by the user. Refreshing simply drops the references to the old text 413*0e209d39SAndroid Build Coastguard Worker * and replaces them with references to the new. 414*0e209d39SAndroid Build Coastguard Worker * 415*0e209d39SAndroid Build Coastguard Worker * Caution: this function is normally used only by very specialized 416*0e209d39SAndroid Build Coastguard Worker * system-level code. One example use case is with garbage collection 417*0e209d39SAndroid Build Coastguard Worker * that moves the text in memory. 418*0e209d39SAndroid Build Coastguard Worker * 419*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 420*0e209d39SAndroid Build Coastguard Worker * @param text The new (moved) text string. 421*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 422*0e209d39SAndroid Build Coastguard Worker * 423*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 424*0e209d39SAndroid Build Coastguard Worker */ 425*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 426*0e209d39SAndroid Build Coastguard Worker uregex_refreshUText(URegularExpression *regexp, 427*0e209d39SAndroid Build Coastguard Worker UText *text, 428*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 429*0e209d39SAndroid Build Coastguard Worker 430*0e209d39SAndroid Build Coastguard Worker /** 431*0e209d39SAndroid Build Coastguard Worker * Attempts to match the input string against the pattern. 432*0e209d39SAndroid Build Coastguard Worker * To succeed, the match must extend to the end of the string, 433*0e209d39SAndroid Build Coastguard Worker * or cover the complete match region. 434*0e209d39SAndroid Build Coastguard Worker * 435*0e209d39SAndroid Build Coastguard Worker * If startIndex >= zero the match operation starts at the specified 436*0e209d39SAndroid Build Coastguard Worker * index and must extend to the end of the input string. Any region 437*0e209d39SAndroid Build Coastguard Worker * that has been specified is reset. 438*0e209d39SAndroid Build Coastguard Worker * 439*0e209d39SAndroid Build Coastguard Worker * If startIndex == -1 the match must cover the input region, or the entire 440*0e209d39SAndroid Build Coastguard Worker * input string if no region has been set. This directly corresponds to 441*0e209d39SAndroid Build Coastguard Worker * Matcher.matches() in Java 442*0e209d39SAndroid Build Coastguard Worker * 443*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 444*0e209d39SAndroid Build Coastguard Worker * @param startIndex The input string (native) index at which to begin matching, or -1 445*0e209d39SAndroid Build Coastguard Worker * to match the input Region. 446*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 447*0e209d39SAndroid Build Coastguard Worker * @return true if there is a match 448*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 449*0e209d39SAndroid Build Coastguard Worker */ 450*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 451*0e209d39SAndroid Build Coastguard Worker uregex_matches(URegularExpression *regexp, 452*0e209d39SAndroid Build Coastguard Worker int32_t startIndex, 453*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 454*0e209d39SAndroid Build Coastguard Worker 455*0e209d39SAndroid Build Coastguard Worker /** 456*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_matches. 457*0e209d39SAndroid Build Coastguard Worker * Attempts to match the input string against the pattern. 458*0e209d39SAndroid Build Coastguard Worker * To succeed, the match must extend to the end of the string, 459*0e209d39SAndroid Build Coastguard Worker * or cover the complete match region. 460*0e209d39SAndroid Build Coastguard Worker * 461*0e209d39SAndroid Build Coastguard Worker * If startIndex >= zero the match operation starts at the specified 462*0e209d39SAndroid Build Coastguard Worker * index and must extend to the end of the input string. Any region 463*0e209d39SAndroid Build Coastguard Worker * that has been specified is reset. 464*0e209d39SAndroid Build Coastguard Worker * 465*0e209d39SAndroid Build Coastguard Worker * If startIndex == -1 the match must cover the input region, or the entire 466*0e209d39SAndroid Build Coastguard Worker * input string if no region has been set. This directly corresponds to 467*0e209d39SAndroid Build Coastguard Worker * Matcher.matches() in Java 468*0e209d39SAndroid Build Coastguard Worker * 469*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 470*0e209d39SAndroid Build Coastguard Worker * @param startIndex The input string (native) index at which to begin matching, or -1 471*0e209d39SAndroid Build Coastguard Worker * to match the input Region. 472*0e209d39SAndroid Build Coastguard Worker * @param status Receives errors detected by this function. 473*0e209d39SAndroid Build Coastguard Worker * @return true if there is a match 474*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 475*0e209d39SAndroid Build Coastguard Worker */ 476*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 477*0e209d39SAndroid Build Coastguard Worker uregex_matches64(URegularExpression *regexp, 478*0e209d39SAndroid Build Coastguard Worker int64_t startIndex, 479*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 480*0e209d39SAndroid Build Coastguard Worker 481*0e209d39SAndroid Build Coastguard Worker /** 482*0e209d39SAndroid Build Coastguard Worker * Attempts to match the input string, starting from the specified index, against the pattern. 483*0e209d39SAndroid Build Coastguard Worker * The match may be of any length, and is not required to extend to the end 484*0e209d39SAndroid Build Coastguard Worker * of the input string. Contrast with uregex_matches(). 485*0e209d39SAndroid Build Coastguard Worker * 486*0e209d39SAndroid Build Coastguard Worker * <p>If startIndex is >= 0 any input region that was set for this 487*0e209d39SAndroid Build Coastguard Worker * URegularExpression is reset before the operation begins. 488*0e209d39SAndroid Build Coastguard Worker * 489*0e209d39SAndroid Build Coastguard Worker * <p>If the specified starting index == -1 the match begins at the start of the input 490*0e209d39SAndroid Build Coastguard Worker * region, or at the start of the full string if no region has been specified. 491*0e209d39SAndroid Build Coastguard Worker * This corresponds directly with Matcher.lookingAt() in Java. 492*0e209d39SAndroid Build Coastguard Worker * 493*0e209d39SAndroid Build Coastguard Worker * <p>If the match succeeds then more information can be obtained via the 494*0e209d39SAndroid Build Coastguard Worker * <code>uregexp_start()</code>, <code>uregexp_end()</code>, 495*0e209d39SAndroid Build Coastguard Worker * and <code>uregex_group()</code> functions.</p> 496*0e209d39SAndroid Build Coastguard Worker * 497*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 498*0e209d39SAndroid Build Coastguard Worker * @param startIndex The input string (native) index at which to begin matching, or 499*0e209d39SAndroid Build Coastguard Worker * -1 to match the Input Region 500*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 501*0e209d39SAndroid Build Coastguard Worker * @return true if there is a match. 502*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 503*0e209d39SAndroid Build Coastguard Worker */ 504*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 505*0e209d39SAndroid Build Coastguard Worker uregex_lookingAt(URegularExpression *regexp, 506*0e209d39SAndroid Build Coastguard Worker int32_t startIndex, 507*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 508*0e209d39SAndroid Build Coastguard Worker 509*0e209d39SAndroid Build Coastguard Worker /** 510*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_lookingAt. 511*0e209d39SAndroid Build Coastguard Worker * Attempts to match the input string, starting from the specified index, against the pattern. 512*0e209d39SAndroid Build Coastguard Worker * The match may be of any length, and is not required to extend to the end 513*0e209d39SAndroid Build Coastguard Worker * of the input string. Contrast with uregex_matches(). 514*0e209d39SAndroid Build Coastguard Worker * 515*0e209d39SAndroid Build Coastguard Worker * <p>If startIndex is >= 0 any input region that was set for this 516*0e209d39SAndroid Build Coastguard Worker * URegularExpression is reset before the operation begins. 517*0e209d39SAndroid Build Coastguard Worker * 518*0e209d39SAndroid Build Coastguard Worker * <p>If the specified starting index == -1 the match begins at the start of the input 519*0e209d39SAndroid Build Coastguard Worker * region, or at the start of the full string if no region has been specified. 520*0e209d39SAndroid Build Coastguard Worker * This corresponds directly with Matcher.lookingAt() in Java. 521*0e209d39SAndroid Build Coastguard Worker * 522*0e209d39SAndroid Build Coastguard Worker * <p>If the match succeeds then more information can be obtained via the 523*0e209d39SAndroid Build Coastguard Worker * <code>uregexp_start()</code>, <code>uregexp_end()</code>, 524*0e209d39SAndroid Build Coastguard Worker * and <code>uregex_group()</code> functions.</p> 525*0e209d39SAndroid Build Coastguard Worker * 526*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 527*0e209d39SAndroid Build Coastguard Worker * @param startIndex The input string (native) index at which to begin matching, or 528*0e209d39SAndroid Build Coastguard Worker * -1 to match the Input Region 529*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 530*0e209d39SAndroid Build Coastguard Worker * @return true if there is a match. 531*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 532*0e209d39SAndroid Build Coastguard Worker */ 533*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 534*0e209d39SAndroid Build Coastguard Worker uregex_lookingAt64(URegularExpression *regexp, 535*0e209d39SAndroid Build Coastguard Worker int64_t startIndex, 536*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 537*0e209d39SAndroid Build Coastguard Worker 538*0e209d39SAndroid Build Coastguard Worker /** 539*0e209d39SAndroid Build Coastguard Worker * Find the first matching substring of the input string that matches the pattern. 540*0e209d39SAndroid Build Coastguard Worker * If startIndex is >= zero the search for a match begins at the specified index, 541*0e209d39SAndroid Build Coastguard Worker * and any match region is reset. This corresponds directly with 542*0e209d39SAndroid Build Coastguard Worker * Matcher.find(startIndex) in Java. 543*0e209d39SAndroid Build Coastguard Worker * 544*0e209d39SAndroid Build Coastguard Worker * If startIndex == -1 the search begins at the start of the input region, 545*0e209d39SAndroid Build Coastguard Worker * or at the start of the full string if no region has been specified. 546*0e209d39SAndroid Build Coastguard Worker * 547*0e209d39SAndroid Build Coastguard Worker * If a match is found, <code>uregex_start(), uregex_end()</code>, and 548*0e209d39SAndroid Build Coastguard Worker * <code>uregex_group()</code> will provide more information regarding the match. 549*0e209d39SAndroid Build Coastguard Worker * 550*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 551*0e209d39SAndroid Build Coastguard Worker * @param startIndex The position (native) in the input string to begin the search, or 552*0e209d39SAndroid Build Coastguard Worker * -1 to search within the Input Region. 553*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 554*0e209d39SAndroid Build Coastguard Worker * @return true if a match is found. 555*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 556*0e209d39SAndroid Build Coastguard Worker */ 557*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 558*0e209d39SAndroid Build Coastguard Worker uregex_find(URegularExpression *regexp, 559*0e209d39SAndroid Build Coastguard Worker int32_t startIndex, 560*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 561*0e209d39SAndroid Build Coastguard Worker 562*0e209d39SAndroid Build Coastguard Worker /** 563*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_find. 564*0e209d39SAndroid Build Coastguard Worker * Find the first matching substring of the input string that matches the pattern. 565*0e209d39SAndroid Build Coastguard Worker * If startIndex is >= zero the search for a match begins at the specified index, 566*0e209d39SAndroid Build Coastguard Worker * and any match region is reset. This corresponds directly with 567*0e209d39SAndroid Build Coastguard Worker * Matcher.find(startIndex) in Java. 568*0e209d39SAndroid Build Coastguard Worker * 569*0e209d39SAndroid Build Coastguard Worker * If startIndex == -1 the search begins at the start of the input region, 570*0e209d39SAndroid Build Coastguard Worker * or at the start of the full string if no region has been specified. 571*0e209d39SAndroid Build Coastguard Worker * 572*0e209d39SAndroid Build Coastguard Worker * If a match is found, <code>uregex_start(), uregex_end()</code>, and 573*0e209d39SAndroid Build Coastguard Worker * <code>uregex_group()</code> will provide more information regarding the match. 574*0e209d39SAndroid Build Coastguard Worker * 575*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 576*0e209d39SAndroid Build Coastguard Worker * @param startIndex The position (native) in the input string to begin the search, or 577*0e209d39SAndroid Build Coastguard Worker * -1 to search within the Input Region. 578*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 579*0e209d39SAndroid Build Coastguard Worker * @return true if a match is found. 580*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 581*0e209d39SAndroid Build Coastguard Worker */ 582*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 583*0e209d39SAndroid Build Coastguard Worker uregex_find64(URegularExpression *regexp, 584*0e209d39SAndroid Build Coastguard Worker int64_t startIndex, 585*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 586*0e209d39SAndroid Build Coastguard Worker 587*0e209d39SAndroid Build Coastguard Worker /** 588*0e209d39SAndroid Build Coastguard Worker * Find the next pattern match in the input string. Begin searching 589*0e209d39SAndroid Build Coastguard Worker * the input at the location following the end of he previous match, 590*0e209d39SAndroid Build Coastguard Worker * or at the start of the string (or region) if there is no 591*0e209d39SAndroid Build Coastguard Worker * previous match. If a match is found, <code>uregex_start(), uregex_end()</code>, and 592*0e209d39SAndroid Build Coastguard Worker * <code>uregex_group()</code> will provide more information regarding the match. 593*0e209d39SAndroid Build Coastguard Worker * 594*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 595*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 596*0e209d39SAndroid Build Coastguard Worker * @return true if a match is found. 597*0e209d39SAndroid Build Coastguard Worker * @see uregex_reset 598*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 599*0e209d39SAndroid Build Coastguard Worker */ 600*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 601*0e209d39SAndroid Build Coastguard Worker uregex_findNext(URegularExpression *regexp, 602*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 603*0e209d39SAndroid Build Coastguard Worker 604*0e209d39SAndroid Build Coastguard Worker /** 605*0e209d39SAndroid Build Coastguard Worker * Get the number of capturing groups in this regular expression's pattern. 606*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 607*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 608*0e209d39SAndroid Build Coastguard Worker * @return the number of capture groups 609*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 610*0e209d39SAndroid Build Coastguard Worker */ 611*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 612*0e209d39SAndroid Build Coastguard Worker uregex_groupCount(URegularExpression *regexp, 613*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 614*0e209d39SAndroid Build Coastguard Worker 615*0e209d39SAndroid Build Coastguard Worker /** 616*0e209d39SAndroid Build Coastguard Worker * Get the group number corresponding to a named capture group. 617*0e209d39SAndroid Build Coastguard Worker * The returned number can be used with any function that access 618*0e209d39SAndroid Build Coastguard Worker * capture groups by number. 619*0e209d39SAndroid Build Coastguard Worker * 620*0e209d39SAndroid Build Coastguard Worker * The function returns an error status if the specified name does not 621*0e209d39SAndroid Build Coastguard Worker * appear in the pattern. 622*0e209d39SAndroid Build Coastguard Worker * 623*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 624*0e209d39SAndroid Build Coastguard Worker * @param groupName The capture group name. 625*0e209d39SAndroid Build Coastguard Worker * @param nameLength The length of the name, or -1 if the name is a 626*0e209d39SAndroid Build Coastguard Worker * nul-terminated string. 627*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 628*0e209d39SAndroid Build Coastguard Worker * 629*0e209d39SAndroid Build Coastguard Worker * @stable ICU 55 630*0e209d39SAndroid Build Coastguard Worker */ 631*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 632*0e209d39SAndroid Build Coastguard Worker uregex_groupNumberFromName(URegularExpression *regexp, 633*0e209d39SAndroid Build Coastguard Worker const UChar *groupName, 634*0e209d39SAndroid Build Coastguard Worker int32_t nameLength, 635*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 636*0e209d39SAndroid Build Coastguard Worker 637*0e209d39SAndroid Build Coastguard Worker 638*0e209d39SAndroid Build Coastguard Worker /** 639*0e209d39SAndroid Build Coastguard Worker * Get the group number corresponding to a named capture group. 640*0e209d39SAndroid Build Coastguard Worker * The returned number can be used with any function that access 641*0e209d39SAndroid Build Coastguard Worker * capture groups by number. 642*0e209d39SAndroid Build Coastguard Worker * 643*0e209d39SAndroid Build Coastguard Worker * The function returns an error status if the specified name does not 644*0e209d39SAndroid Build Coastguard Worker * appear in the pattern. 645*0e209d39SAndroid Build Coastguard Worker * 646*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 647*0e209d39SAndroid Build Coastguard Worker * @param groupName The capture group name, 648*0e209d39SAndroid Build Coastguard Worker * platform invariant characters only. 649*0e209d39SAndroid Build Coastguard Worker * @param nameLength The length of the name, or -1 if the name is 650*0e209d39SAndroid Build Coastguard Worker * nul-terminated. 651*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 652*0e209d39SAndroid Build Coastguard Worker * 653*0e209d39SAndroid Build Coastguard Worker * @stable ICU 55 654*0e209d39SAndroid Build Coastguard Worker */ 655*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 656*0e209d39SAndroid Build Coastguard Worker uregex_groupNumberFromCName(URegularExpression *regexp, 657*0e209d39SAndroid Build Coastguard Worker const char *groupName, 658*0e209d39SAndroid Build Coastguard Worker int32_t nameLength, 659*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 660*0e209d39SAndroid Build Coastguard Worker 661*0e209d39SAndroid Build Coastguard Worker /** Extract the string for the specified matching expression or subexpression. 662*0e209d39SAndroid Build Coastguard Worker * Group #0 is the complete string of matched text. 663*0e209d39SAndroid Build Coastguard Worker * Group #1 is the text matched by the first set of capturing parentheses. 664*0e209d39SAndroid Build Coastguard Worker * 665*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 666*0e209d39SAndroid Build Coastguard Worker * @param groupNum The capture group to extract. Group 0 is the complete 667*0e209d39SAndroid Build Coastguard Worker * match. The value of this parameter must be 668*0e209d39SAndroid Build Coastguard Worker * less than or equal to the number of capture groups in 669*0e209d39SAndroid Build Coastguard Worker * the pattern. 670*0e209d39SAndroid Build Coastguard Worker * @param dest Buffer to receive the matching string data 671*0e209d39SAndroid Build Coastguard Worker * @param destCapacity Capacity of the dest buffer. 672*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 673*0e209d39SAndroid Build Coastguard Worker * @return Length of matching data, 674*0e209d39SAndroid Build Coastguard Worker * or -1 if no applicable match. 675*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 676*0e209d39SAndroid Build Coastguard Worker */ 677*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 678*0e209d39SAndroid Build Coastguard Worker uregex_group(URegularExpression *regexp, 679*0e209d39SAndroid Build Coastguard Worker int32_t groupNum, 680*0e209d39SAndroid Build Coastguard Worker UChar *dest, 681*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 682*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 683*0e209d39SAndroid Build Coastguard Worker 684*0e209d39SAndroid Build Coastguard Worker /** Returns a shallow immutable clone of the entire input string with the current index set 685*0e209d39SAndroid Build Coastguard Worker * to the beginning of the requested capture group. The capture group length is also 686*0e209d39SAndroid Build Coastguard Worker * returned via groupLength. 687*0e209d39SAndroid Build Coastguard Worker * Group #0 is the complete string of matched text. 688*0e209d39SAndroid Build Coastguard Worker * Group #1 is the text matched by the first set of capturing parentheses. 689*0e209d39SAndroid Build Coastguard Worker * 690*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 691*0e209d39SAndroid Build Coastguard Worker * @param groupNum The capture group to extract. Group 0 is the complete 692*0e209d39SAndroid Build Coastguard Worker * match. The value of this parameter must be 693*0e209d39SAndroid Build Coastguard Worker * less than or equal to the number of capture groups in 694*0e209d39SAndroid Build Coastguard Worker * the pattern. 695*0e209d39SAndroid Build Coastguard Worker * @param dest A mutable UText in which to store the current input. 696*0e209d39SAndroid Build Coastguard Worker * If NULL, a new UText will be created as an immutable shallow clone 697*0e209d39SAndroid Build Coastguard Worker * of the entire input string. 698*0e209d39SAndroid Build Coastguard Worker * @param groupLength The group length of the desired capture group. Output parameter. 699*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 700*0e209d39SAndroid Build Coastguard Worker * @return The subject text currently associated with this regular expression. 701*0e209d39SAndroid Build Coastguard Worker * If a pre-allocated UText was provided, it will always be used and returned. 702*0e209d39SAndroid Build Coastguard Worker 703*0e209d39SAndroid Build Coastguard Worker * 704*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 705*0e209d39SAndroid Build Coastguard Worker */ 706*0e209d39SAndroid Build Coastguard Worker U_CAPI UText * U_EXPORT2 707*0e209d39SAndroid Build Coastguard Worker uregex_groupUText(URegularExpression *regexp, 708*0e209d39SAndroid Build Coastguard Worker int32_t groupNum, 709*0e209d39SAndroid Build Coastguard Worker UText *dest, 710*0e209d39SAndroid Build Coastguard Worker int64_t *groupLength, 711*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 712*0e209d39SAndroid Build Coastguard Worker 713*0e209d39SAndroid Build Coastguard Worker /** 714*0e209d39SAndroid Build Coastguard Worker * Returns the index in the input string of the start of the text matched by the 715*0e209d39SAndroid Build Coastguard Worker * specified capture group during the previous match operation. Return -1 if 716*0e209d39SAndroid Build Coastguard Worker * the capture group was not part of the last match. 717*0e209d39SAndroid Build Coastguard Worker * Group #0 refers to the complete range of matched text. 718*0e209d39SAndroid Build Coastguard Worker * Group #1 refers to the text matched by the first set of capturing parentheses. 719*0e209d39SAndroid Build Coastguard Worker * 720*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 721*0e209d39SAndroid Build Coastguard Worker * @param groupNum The capture group number 722*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 723*0e209d39SAndroid Build Coastguard Worker * @return the starting (native) position in the input of the text matched 724*0e209d39SAndroid Build Coastguard Worker * by the specified group. 725*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 726*0e209d39SAndroid Build Coastguard Worker */ 727*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 728*0e209d39SAndroid Build Coastguard Worker uregex_start(URegularExpression *regexp, 729*0e209d39SAndroid Build Coastguard Worker int32_t groupNum, 730*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 731*0e209d39SAndroid Build Coastguard Worker 732*0e209d39SAndroid Build Coastguard Worker /** 733*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_start. 734*0e209d39SAndroid Build Coastguard Worker * Returns the index in the input string of the start of the text matched by the 735*0e209d39SAndroid Build Coastguard Worker * specified capture group during the previous match operation. Return -1 if 736*0e209d39SAndroid Build Coastguard Worker * the capture group was not part of the last match. 737*0e209d39SAndroid Build Coastguard Worker * Group #0 refers to the complete range of matched text. 738*0e209d39SAndroid Build Coastguard Worker * Group #1 refers to the text matched by the first set of capturing parentheses. 739*0e209d39SAndroid Build Coastguard Worker * 740*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 741*0e209d39SAndroid Build Coastguard Worker * @param groupNum The capture group number 742*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 743*0e209d39SAndroid Build Coastguard Worker * @return the starting (native) position in the input of the text matched 744*0e209d39SAndroid Build Coastguard Worker * by the specified group. 745*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 746*0e209d39SAndroid Build Coastguard Worker */ 747*0e209d39SAndroid Build Coastguard Worker U_CAPI int64_t U_EXPORT2 748*0e209d39SAndroid Build Coastguard Worker uregex_start64(URegularExpression *regexp, 749*0e209d39SAndroid Build Coastguard Worker int32_t groupNum, 750*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 751*0e209d39SAndroid Build Coastguard Worker 752*0e209d39SAndroid Build Coastguard Worker /** 753*0e209d39SAndroid Build Coastguard Worker * Returns the index in the input string of the position following the end 754*0e209d39SAndroid Build Coastguard Worker * of the text matched by the specified capture group. 755*0e209d39SAndroid Build Coastguard Worker * Return -1 if the capture group was not part of the last match. 756*0e209d39SAndroid Build Coastguard Worker * Group #0 refers to the complete range of matched text. 757*0e209d39SAndroid Build Coastguard Worker * Group #1 refers to the text matched by the first set of capturing parentheses. 758*0e209d39SAndroid Build Coastguard Worker * 759*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 760*0e209d39SAndroid Build Coastguard Worker * @param groupNum The capture group number 761*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 762*0e209d39SAndroid Build Coastguard Worker * @return the (native) index of the position following the last matched character. 763*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 764*0e209d39SAndroid Build Coastguard Worker */ 765*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 766*0e209d39SAndroid Build Coastguard Worker uregex_end(URegularExpression *regexp, 767*0e209d39SAndroid Build Coastguard Worker int32_t groupNum, 768*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 769*0e209d39SAndroid Build Coastguard Worker 770*0e209d39SAndroid Build Coastguard Worker /** 771*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_end. 772*0e209d39SAndroid Build Coastguard Worker * Returns the index in the input string of the position following the end 773*0e209d39SAndroid Build Coastguard Worker * of the text matched by the specified capture group. 774*0e209d39SAndroid Build Coastguard Worker * Return -1 if the capture group was not part of the last match. 775*0e209d39SAndroid Build Coastguard Worker * Group #0 refers to the complete range of matched text. 776*0e209d39SAndroid Build Coastguard Worker * Group #1 refers to the text matched by the first set of capturing parentheses. 777*0e209d39SAndroid Build Coastguard Worker * 778*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 779*0e209d39SAndroid Build Coastguard Worker * @param groupNum The capture group number 780*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 781*0e209d39SAndroid Build Coastguard Worker * @return the (native) index of the position following the last matched character. 782*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 783*0e209d39SAndroid Build Coastguard Worker */ 784*0e209d39SAndroid Build Coastguard Worker U_CAPI int64_t U_EXPORT2 785*0e209d39SAndroid Build Coastguard Worker uregex_end64(URegularExpression *regexp, 786*0e209d39SAndroid Build Coastguard Worker int32_t groupNum, 787*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 788*0e209d39SAndroid Build Coastguard Worker 789*0e209d39SAndroid Build Coastguard Worker /** 790*0e209d39SAndroid Build Coastguard Worker * Reset any saved state from the previous match. Has the effect of 791*0e209d39SAndroid Build Coastguard Worker * causing uregex_findNext to begin at the specified index, and causing 792*0e209d39SAndroid Build Coastguard Worker * uregex_start(), uregex_end() and uregex_group() to return an error 793*0e209d39SAndroid Build Coastguard Worker * indicating that there is no match information available. Clears any 794*0e209d39SAndroid Build Coastguard Worker * match region that may have been set. 795*0e209d39SAndroid Build Coastguard Worker * 796*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 797*0e209d39SAndroid Build Coastguard Worker * @param index The position (native) in the text at which a 798*0e209d39SAndroid Build Coastguard Worker * uregex_findNext() should begin searching. 799*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 800*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 801*0e209d39SAndroid Build Coastguard Worker */ 802*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 803*0e209d39SAndroid Build Coastguard Worker uregex_reset(URegularExpression *regexp, 804*0e209d39SAndroid Build Coastguard Worker int32_t index, 805*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 806*0e209d39SAndroid Build Coastguard Worker 807*0e209d39SAndroid Build Coastguard Worker /** 808*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_reset. 809*0e209d39SAndroid Build Coastguard Worker * Reset any saved state from the previous match. Has the effect of 810*0e209d39SAndroid Build Coastguard Worker * causing uregex_findNext to begin at the specified index, and causing 811*0e209d39SAndroid Build Coastguard Worker * uregex_start(), uregex_end() and uregex_group() to return an error 812*0e209d39SAndroid Build Coastguard Worker * indicating that there is no match information available. Clears any 813*0e209d39SAndroid Build Coastguard Worker * match region that may have been set. 814*0e209d39SAndroid Build Coastguard Worker * 815*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 816*0e209d39SAndroid Build Coastguard Worker * @param index The position (native) in the text at which a 817*0e209d39SAndroid Build Coastguard Worker * uregex_findNext() should begin searching. 818*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 819*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 820*0e209d39SAndroid Build Coastguard Worker */ 821*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 822*0e209d39SAndroid Build Coastguard Worker uregex_reset64(URegularExpression *regexp, 823*0e209d39SAndroid Build Coastguard Worker int64_t index, 824*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 825*0e209d39SAndroid Build Coastguard Worker 826*0e209d39SAndroid Build Coastguard Worker /** 827*0e209d39SAndroid Build Coastguard Worker * Sets the limits of the matching region for this URegularExpression. 828*0e209d39SAndroid Build Coastguard Worker * The region is the part of the input string that will be considered when matching. 829*0e209d39SAndroid Build Coastguard Worker * Invoking this method resets any saved state from the previous match, 830*0e209d39SAndroid Build Coastguard Worker * then sets the region to start at the index specified by the start parameter 831*0e209d39SAndroid Build Coastguard Worker * and end at the index specified by the end parameter. 832*0e209d39SAndroid Build Coastguard Worker * 833*0e209d39SAndroid Build Coastguard Worker * Depending on the transparency and anchoring being used (see useTransparentBounds 834*0e209d39SAndroid Build Coastguard Worker * and useAnchoringBounds), certain constructs such as anchors may behave differently 835*0e209d39SAndroid Build Coastguard Worker * at or around the boundaries of the region 836*0e209d39SAndroid Build Coastguard Worker * 837*0e209d39SAndroid Build Coastguard Worker * The function will fail if start is greater than limit, or if either index 838*0e209d39SAndroid Build Coastguard Worker * is less than zero or greater than the length of the string being matched. 839*0e209d39SAndroid Build Coastguard Worker * 840*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 841*0e209d39SAndroid Build Coastguard Worker * @param regionStart The (native) index to begin searches at. 842*0e209d39SAndroid Build Coastguard Worker * @param regionLimit The (native) index to end searches at (exclusive). 843*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 844*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 845*0e209d39SAndroid Build Coastguard Worker */ 846*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 847*0e209d39SAndroid Build Coastguard Worker uregex_setRegion(URegularExpression *regexp, 848*0e209d39SAndroid Build Coastguard Worker int32_t regionStart, 849*0e209d39SAndroid Build Coastguard Worker int32_t regionLimit, 850*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 851*0e209d39SAndroid Build Coastguard Worker 852*0e209d39SAndroid Build Coastguard Worker /** 853*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_setRegion. 854*0e209d39SAndroid Build Coastguard Worker * Sets the limits of the matching region for this URegularExpression. 855*0e209d39SAndroid Build Coastguard Worker * The region is the part of the input string that will be considered when matching. 856*0e209d39SAndroid Build Coastguard Worker * Invoking this method resets any saved state from the previous match, 857*0e209d39SAndroid Build Coastguard Worker * then sets the region to start at the index specified by the start parameter 858*0e209d39SAndroid Build Coastguard Worker * and end at the index specified by the end parameter. 859*0e209d39SAndroid Build Coastguard Worker * 860*0e209d39SAndroid Build Coastguard Worker * Depending on the transparency and anchoring being used (see useTransparentBounds 861*0e209d39SAndroid Build Coastguard Worker * and useAnchoringBounds), certain constructs such as anchors may behave differently 862*0e209d39SAndroid Build Coastguard Worker * at or around the boundaries of the region 863*0e209d39SAndroid Build Coastguard Worker * 864*0e209d39SAndroid Build Coastguard Worker * The function will fail if start is greater than limit, or if either index 865*0e209d39SAndroid Build Coastguard Worker * is less than zero or greater than the length of the string being matched. 866*0e209d39SAndroid Build Coastguard Worker * 867*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 868*0e209d39SAndroid Build Coastguard Worker * @param regionStart The (native) index to begin searches at. 869*0e209d39SAndroid Build Coastguard Worker * @param regionLimit The (native) index to end searches at (exclusive). 870*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 871*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 872*0e209d39SAndroid Build Coastguard Worker */ 873*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 874*0e209d39SAndroid Build Coastguard Worker uregex_setRegion64(URegularExpression *regexp, 875*0e209d39SAndroid Build Coastguard Worker int64_t regionStart, 876*0e209d39SAndroid Build Coastguard Worker int64_t regionLimit, 877*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 878*0e209d39SAndroid Build Coastguard Worker 879*0e209d39SAndroid Build Coastguard Worker /** 880*0e209d39SAndroid Build Coastguard Worker * Set the matching region and the starting index for subsequent matches 881*0e209d39SAndroid Build Coastguard Worker * in a single operation. 882*0e209d39SAndroid Build Coastguard Worker * This is useful because the usual function for setting the starting 883*0e209d39SAndroid Build Coastguard Worker * index, urgex_reset(), also resets any region limits. 884*0e209d39SAndroid Build Coastguard Worker * 885*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 886*0e209d39SAndroid Build Coastguard Worker * @param regionStart The (native) index to begin searches at. 887*0e209d39SAndroid Build Coastguard Worker * @param regionLimit The (native) index to end searches at (exclusive). 888*0e209d39SAndroid Build Coastguard Worker * @param startIndex The index in the input text at which the next 889*0e209d39SAndroid Build Coastguard Worker * match operation should begin. 890*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 891*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 892*0e209d39SAndroid Build Coastguard Worker */ 893*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 894*0e209d39SAndroid Build Coastguard Worker uregex_setRegionAndStart(URegularExpression *regexp, 895*0e209d39SAndroid Build Coastguard Worker int64_t regionStart, 896*0e209d39SAndroid Build Coastguard Worker int64_t regionLimit, 897*0e209d39SAndroid Build Coastguard Worker int64_t startIndex, 898*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 899*0e209d39SAndroid Build Coastguard Worker 900*0e209d39SAndroid Build Coastguard Worker /** 901*0e209d39SAndroid Build Coastguard Worker * Reports the start index of the matching region. Any matches found are limited to 902*0e209d39SAndroid Build Coastguard Worker * to the region bounded by regionStart (inclusive) and regionEnd (exclusive). 903*0e209d39SAndroid Build Coastguard Worker * 904*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 905*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 906*0e209d39SAndroid Build Coastguard Worker * @return The starting (native) index of this matcher's region. 907*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 908*0e209d39SAndroid Build Coastguard Worker */ 909*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 910*0e209d39SAndroid Build Coastguard Worker uregex_regionStart(const URegularExpression *regexp, 911*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 912*0e209d39SAndroid Build Coastguard Worker 913*0e209d39SAndroid Build Coastguard Worker /** 914*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_regionStart. 915*0e209d39SAndroid Build Coastguard Worker * Reports the start index of the matching region. Any matches found are limited to 916*0e209d39SAndroid Build Coastguard Worker * to the region bounded by regionStart (inclusive) and regionEnd (exclusive). 917*0e209d39SAndroid Build Coastguard Worker * 918*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 919*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 920*0e209d39SAndroid Build Coastguard Worker * @return The starting (native) index of this matcher's region. 921*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 922*0e209d39SAndroid Build Coastguard Worker */ 923*0e209d39SAndroid Build Coastguard Worker U_CAPI int64_t U_EXPORT2 924*0e209d39SAndroid Build Coastguard Worker uregex_regionStart64(const URegularExpression *regexp, 925*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 926*0e209d39SAndroid Build Coastguard Worker 927*0e209d39SAndroid Build Coastguard Worker /** 928*0e209d39SAndroid Build Coastguard Worker * Reports the end index (exclusive) of the matching region for this URegularExpression. 929*0e209d39SAndroid Build Coastguard Worker * Any matches found are limited to to the region bounded by regionStart (inclusive) 930*0e209d39SAndroid Build Coastguard Worker * and regionEnd (exclusive). 931*0e209d39SAndroid Build Coastguard Worker * 932*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 933*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 934*0e209d39SAndroid Build Coastguard Worker * @return The ending point (native) of this matcher's region. 935*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 936*0e209d39SAndroid Build Coastguard Worker */ 937*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 938*0e209d39SAndroid Build Coastguard Worker uregex_regionEnd(const URegularExpression *regexp, 939*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 940*0e209d39SAndroid Build Coastguard Worker 941*0e209d39SAndroid Build Coastguard Worker /** 942*0e209d39SAndroid Build Coastguard Worker * 64bit version of uregex_regionEnd. 943*0e209d39SAndroid Build Coastguard Worker * Reports the end index (exclusive) of the matching region for this URegularExpression. 944*0e209d39SAndroid Build Coastguard Worker * Any matches found are limited to to the region bounded by regionStart (inclusive) 945*0e209d39SAndroid Build Coastguard Worker * and regionEnd (exclusive). 946*0e209d39SAndroid Build Coastguard Worker * 947*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 948*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 949*0e209d39SAndroid Build Coastguard Worker * @return The ending point (native) of this matcher's region. 950*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 951*0e209d39SAndroid Build Coastguard Worker */ 952*0e209d39SAndroid Build Coastguard Worker U_CAPI int64_t U_EXPORT2 953*0e209d39SAndroid Build Coastguard Worker uregex_regionEnd64(const URegularExpression *regexp, 954*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 955*0e209d39SAndroid Build Coastguard Worker 956*0e209d39SAndroid Build Coastguard Worker /** 957*0e209d39SAndroid Build Coastguard Worker * Queries the transparency of region bounds for this URegularExpression. 958*0e209d39SAndroid Build Coastguard Worker * See useTransparentBounds for a description of transparent and opaque bounds. 959*0e209d39SAndroid Build Coastguard Worker * By default, matching boundaries are opaque. 960*0e209d39SAndroid Build Coastguard Worker * 961*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 962*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 963*0e209d39SAndroid Build Coastguard Worker * @return true if this matcher is using opaque bounds, false if it is not. 964*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 965*0e209d39SAndroid Build Coastguard Worker */ 966*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 967*0e209d39SAndroid Build Coastguard Worker uregex_hasTransparentBounds(const URegularExpression *regexp, 968*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 969*0e209d39SAndroid Build Coastguard Worker 970*0e209d39SAndroid Build Coastguard Worker 971*0e209d39SAndroid Build Coastguard Worker /** 972*0e209d39SAndroid Build Coastguard Worker * Sets the transparency of region bounds for this URegularExpression. 973*0e209d39SAndroid Build Coastguard Worker * Invoking this function with an argument of true will set matches to use transparent bounds. 974*0e209d39SAndroid Build Coastguard Worker * If the boolean argument is false, then opaque bounds will be used. 975*0e209d39SAndroid Build Coastguard Worker * 976*0e209d39SAndroid Build Coastguard Worker * Using transparent bounds, the boundaries of the matching region are transparent 977*0e209d39SAndroid Build Coastguard Worker * to lookahead, lookbehind, and boundary matching constructs. Those constructs can 978*0e209d39SAndroid Build Coastguard Worker * see text beyond the boundaries of the region while checking for a match. 979*0e209d39SAndroid Build Coastguard Worker * 980*0e209d39SAndroid Build Coastguard Worker * With opaque bounds, no text outside of the matching region is visible to lookahead, 981*0e209d39SAndroid Build Coastguard Worker * lookbehind, and boundary matching constructs. 982*0e209d39SAndroid Build Coastguard Worker * 983*0e209d39SAndroid Build Coastguard Worker * By default, opaque bounds are used. 984*0e209d39SAndroid Build Coastguard Worker * 985*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 986*0e209d39SAndroid Build Coastguard Worker * @param b true for transparent bounds; false for opaque bounds 987*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 988*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 989*0e209d39SAndroid Build Coastguard Worker **/ 990*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 991*0e209d39SAndroid Build Coastguard Worker uregex_useTransparentBounds(URegularExpression *regexp, 992*0e209d39SAndroid Build Coastguard Worker UBool b, 993*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 994*0e209d39SAndroid Build Coastguard Worker 995*0e209d39SAndroid Build Coastguard Worker 996*0e209d39SAndroid Build Coastguard Worker /** 997*0e209d39SAndroid Build Coastguard Worker * Return true if this URegularExpression is using anchoring bounds. 998*0e209d39SAndroid Build Coastguard Worker * By default, anchoring region bounds are used. 999*0e209d39SAndroid Build Coastguard Worker * 1000*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1001*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 1002*0e209d39SAndroid Build Coastguard Worker * @return true if this matcher is using anchoring bounds. 1003*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1004*0e209d39SAndroid Build Coastguard Worker */ 1005*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 1006*0e209d39SAndroid Build Coastguard Worker uregex_hasAnchoringBounds(const URegularExpression *regexp, 1007*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1008*0e209d39SAndroid Build Coastguard Worker 1009*0e209d39SAndroid Build Coastguard Worker 1010*0e209d39SAndroid Build Coastguard Worker /** 1011*0e209d39SAndroid Build Coastguard Worker * Set whether this URegularExpression is using Anchoring Bounds for its region. 1012*0e209d39SAndroid Build Coastguard Worker * With anchoring bounds, pattern anchors such as ^ and $ will match at the start 1013*0e209d39SAndroid Build Coastguard Worker * and end of the region. Without Anchoring Bounds, anchors will only match at 1014*0e209d39SAndroid Build Coastguard Worker * the positions they would in the complete text. 1015*0e209d39SAndroid Build Coastguard Worker * 1016*0e209d39SAndroid Build Coastguard Worker * Anchoring Bounds are the default for regions. 1017*0e209d39SAndroid Build Coastguard Worker * 1018*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1019*0e209d39SAndroid Build Coastguard Worker * @param b true if to enable anchoring bounds; false to disable them. 1020*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 1021*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1022*0e209d39SAndroid Build Coastguard Worker */ 1023*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1024*0e209d39SAndroid Build Coastguard Worker uregex_useAnchoringBounds(URegularExpression *regexp, 1025*0e209d39SAndroid Build Coastguard Worker UBool b, 1026*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1027*0e209d39SAndroid Build Coastguard Worker 1028*0e209d39SAndroid Build Coastguard Worker /** 1029*0e209d39SAndroid Build Coastguard Worker * Return true if the most recent matching operation touched the 1030*0e209d39SAndroid Build Coastguard Worker * end of the text being processed. In this case, additional input text could 1031*0e209d39SAndroid Build Coastguard Worker * change the results of that match. 1032*0e209d39SAndroid Build Coastguard Worker * 1033*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1034*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 1035*0e209d39SAndroid Build Coastguard Worker * @return true if the most recent match hit the end of input 1036*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1037*0e209d39SAndroid Build Coastguard Worker */ 1038*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 1039*0e209d39SAndroid Build Coastguard Worker uregex_hitEnd(const URegularExpression *regexp, 1040*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1041*0e209d39SAndroid Build Coastguard Worker 1042*0e209d39SAndroid Build Coastguard Worker /** 1043*0e209d39SAndroid Build Coastguard Worker * Return true the most recent match succeeded and additional input could cause 1044*0e209d39SAndroid Build Coastguard Worker * it to fail. If this function returns false and a match was found, then more input 1045*0e209d39SAndroid Build Coastguard Worker * might change the match but the match won't be lost. If a match was not found, 1046*0e209d39SAndroid Build Coastguard Worker * then requireEnd has no meaning. 1047*0e209d39SAndroid Build Coastguard Worker * 1048*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1049*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors. 1050*0e209d39SAndroid Build Coastguard Worker * @return true if more input could cause the most recent match to no longer match. 1051*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1052*0e209d39SAndroid Build Coastguard Worker */ 1053*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 1054*0e209d39SAndroid Build Coastguard Worker uregex_requireEnd(const URegularExpression *regexp, 1055*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1056*0e209d39SAndroid Build Coastguard Worker 1057*0e209d39SAndroid Build Coastguard Worker 1058*0e209d39SAndroid Build Coastguard Worker 1059*0e209d39SAndroid Build Coastguard Worker 1060*0e209d39SAndroid Build Coastguard Worker 1061*0e209d39SAndroid Build Coastguard Worker /** 1062*0e209d39SAndroid Build Coastguard Worker * Replaces every substring of the input that matches the pattern 1063*0e209d39SAndroid Build Coastguard Worker * with the given replacement string. This is a convenience function that 1064*0e209d39SAndroid Build Coastguard Worker * provides a complete find-and-replace-all operation. 1065*0e209d39SAndroid Build Coastguard Worker * 1066*0e209d39SAndroid Build Coastguard Worker * This method scans the input string looking for matches of the pattern. 1067*0e209d39SAndroid Build Coastguard Worker * Input that is not part of any match is copied unchanged to the 1068*0e209d39SAndroid Build Coastguard Worker * destination buffer. Matched regions are replaced in the output 1069*0e209d39SAndroid Build Coastguard Worker * buffer by the replacement string. The replacement string may contain 1070*0e209d39SAndroid Build Coastguard Worker * references to capture groups; these take the form of $1, $2, etc. 1071*0e209d39SAndroid Build Coastguard Worker * 1072*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1073*0e209d39SAndroid Build Coastguard Worker * @param replacementText A string containing the replacement text. 1074*0e209d39SAndroid Build Coastguard Worker * @param replacementLength The length of the replacement string, or 1075*0e209d39SAndroid Build Coastguard Worker * -1 if it is NUL terminated. 1076*0e209d39SAndroid Build Coastguard Worker * @param destBuf A (UChar *) buffer that will receive the result. 1077*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The capacity of the destination buffer. 1078*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1079*0e209d39SAndroid Build Coastguard Worker * @return The length of the string resulting from the find 1080*0e209d39SAndroid Build Coastguard Worker * and replace operation. In the event that the 1081*0e209d39SAndroid Build Coastguard Worker * destination capacity is inadequate, the return value 1082*0e209d39SAndroid Build Coastguard Worker * is still the full length of the untruncated string. 1083*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 1084*0e209d39SAndroid Build Coastguard Worker */ 1085*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1086*0e209d39SAndroid Build Coastguard Worker uregex_replaceAll(URegularExpression *regexp, 1087*0e209d39SAndroid Build Coastguard Worker const UChar *replacementText, 1088*0e209d39SAndroid Build Coastguard Worker int32_t replacementLength, 1089*0e209d39SAndroid Build Coastguard Worker UChar *destBuf, 1090*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1091*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1092*0e209d39SAndroid Build Coastguard Worker 1093*0e209d39SAndroid Build Coastguard Worker /** 1094*0e209d39SAndroid Build Coastguard Worker * Replaces every substring of the input that matches the pattern 1095*0e209d39SAndroid Build Coastguard Worker * with the given replacement string. This is a convenience function that 1096*0e209d39SAndroid Build Coastguard Worker * provides a complete find-and-replace-all operation. 1097*0e209d39SAndroid Build Coastguard Worker * 1098*0e209d39SAndroid Build Coastguard Worker * This method scans the input string looking for matches of the pattern. 1099*0e209d39SAndroid Build Coastguard Worker * Input that is not part of any match is copied unchanged to the 1100*0e209d39SAndroid Build Coastguard Worker * destination buffer. Matched regions are replaced in the output 1101*0e209d39SAndroid Build Coastguard Worker * buffer by the replacement string. The replacement string may contain 1102*0e209d39SAndroid Build Coastguard Worker * references to capture groups; these take the form of $1, $2, etc. 1103*0e209d39SAndroid Build Coastguard Worker * 1104*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1105*0e209d39SAndroid Build Coastguard Worker * @param replacement A string containing the replacement text. 1106*0e209d39SAndroid Build Coastguard Worker * @param dest A mutable UText that will receive the result. 1107*0e209d39SAndroid Build Coastguard Worker * If NULL, a new UText will be created (which may not be mutable). 1108*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1109*0e209d39SAndroid Build Coastguard Worker * @return A UText containing the results of the find and replace. 1110*0e209d39SAndroid Build Coastguard Worker * If a pre-allocated UText was provided, it will always be used and returned. 1111*0e209d39SAndroid Build Coastguard Worker * 1112*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1113*0e209d39SAndroid Build Coastguard Worker */ 1114*0e209d39SAndroid Build Coastguard Worker U_CAPI UText * U_EXPORT2 1115*0e209d39SAndroid Build Coastguard Worker uregex_replaceAllUText(URegularExpression *regexp, 1116*0e209d39SAndroid Build Coastguard Worker UText *replacement, 1117*0e209d39SAndroid Build Coastguard Worker UText *dest, 1118*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1119*0e209d39SAndroid Build Coastguard Worker 1120*0e209d39SAndroid Build Coastguard Worker /** 1121*0e209d39SAndroid Build Coastguard Worker * Replaces the first substring of the input that matches the pattern 1122*0e209d39SAndroid Build Coastguard Worker * with the given replacement string. This is a convenience function that 1123*0e209d39SAndroid Build Coastguard Worker * provides a complete find-and-replace operation. 1124*0e209d39SAndroid Build Coastguard Worker * 1125*0e209d39SAndroid Build Coastguard Worker * This method scans the input string looking for a match of the pattern. 1126*0e209d39SAndroid Build Coastguard Worker * All input that is not part of the match is copied unchanged to the 1127*0e209d39SAndroid Build Coastguard Worker * destination buffer. The matched region is replaced in the output 1128*0e209d39SAndroid Build Coastguard Worker * buffer by the replacement string. The replacement string may contain 1129*0e209d39SAndroid Build Coastguard Worker * references to capture groups; these take the form of $1, $2, etc. 1130*0e209d39SAndroid Build Coastguard Worker * 1131*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1132*0e209d39SAndroid Build Coastguard Worker * @param replacementText A string containing the replacement text. 1133*0e209d39SAndroid Build Coastguard Worker * @param replacementLength The length of the replacement string, or 1134*0e209d39SAndroid Build Coastguard Worker * -1 if it is NUL terminated. 1135*0e209d39SAndroid Build Coastguard Worker * @param destBuf A (UChar *) buffer that will receive the result. 1136*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The capacity of the destination buffer. 1137*0e209d39SAndroid Build Coastguard Worker * @param status a reference to a UErrorCode to receive any errors. 1138*0e209d39SAndroid Build Coastguard Worker * @return The length of the string resulting from the find 1139*0e209d39SAndroid Build Coastguard Worker * and replace operation. In the event that the 1140*0e209d39SAndroid Build Coastguard Worker * destination capacity is inadequate, the return value 1141*0e209d39SAndroid Build Coastguard Worker * is still the full length of the untruncated string. 1142*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 1143*0e209d39SAndroid Build Coastguard Worker */ 1144*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1145*0e209d39SAndroid Build Coastguard Worker uregex_replaceFirst(URegularExpression *regexp, 1146*0e209d39SAndroid Build Coastguard Worker const UChar *replacementText, 1147*0e209d39SAndroid Build Coastguard Worker int32_t replacementLength, 1148*0e209d39SAndroid Build Coastguard Worker UChar *destBuf, 1149*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1150*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1151*0e209d39SAndroid Build Coastguard Worker 1152*0e209d39SAndroid Build Coastguard Worker /** 1153*0e209d39SAndroid Build Coastguard Worker * Replaces the first substring of the input that matches the pattern 1154*0e209d39SAndroid Build Coastguard Worker * with the given replacement string. This is a convenience function that 1155*0e209d39SAndroid Build Coastguard Worker * provides a complete find-and-replace operation. 1156*0e209d39SAndroid Build Coastguard Worker * 1157*0e209d39SAndroid Build Coastguard Worker * This method scans the input string looking for a match of the pattern. 1158*0e209d39SAndroid Build Coastguard Worker * All input that is not part of the match is copied unchanged to the 1159*0e209d39SAndroid Build Coastguard Worker * destination buffer. The matched region is replaced in the output 1160*0e209d39SAndroid Build Coastguard Worker * buffer by the replacement string. The replacement string may contain 1161*0e209d39SAndroid Build Coastguard Worker * references to capture groups; these take the form of $1, $2, etc. 1162*0e209d39SAndroid Build Coastguard Worker * 1163*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1164*0e209d39SAndroid Build Coastguard Worker * @param replacement A string containing the replacement text. 1165*0e209d39SAndroid Build Coastguard Worker * @param dest A mutable UText that will receive the result. 1166*0e209d39SAndroid Build Coastguard Worker * If NULL, a new UText will be created (which may not be mutable). 1167*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1168*0e209d39SAndroid Build Coastguard Worker * @return A UText containing the results of the find and replace. 1169*0e209d39SAndroid Build Coastguard Worker * If a pre-allocated UText was provided, it will always be used and returned. 1170*0e209d39SAndroid Build Coastguard Worker * 1171*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1172*0e209d39SAndroid Build Coastguard Worker */ 1173*0e209d39SAndroid Build Coastguard Worker U_CAPI UText * U_EXPORT2 1174*0e209d39SAndroid Build Coastguard Worker uregex_replaceFirstUText(URegularExpression *regexp, 1175*0e209d39SAndroid Build Coastguard Worker UText *replacement, 1176*0e209d39SAndroid Build Coastguard Worker UText *dest, 1177*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1178*0e209d39SAndroid Build Coastguard Worker 1179*0e209d39SAndroid Build Coastguard Worker /** 1180*0e209d39SAndroid Build Coastguard Worker * Implements a replace operation intended to be used as part of an 1181*0e209d39SAndroid Build Coastguard Worker * incremental find-and-replace. 1182*0e209d39SAndroid Build Coastguard Worker * 1183*0e209d39SAndroid Build Coastguard Worker * <p>The input string, starting from the end of the previous match and ending at 1184*0e209d39SAndroid Build Coastguard Worker * the start of the current match, is appended to the destination string. Then the 1185*0e209d39SAndroid Build Coastguard Worker * replacement string is appended to the output string, 1186*0e209d39SAndroid Build Coastguard Worker * including handling any substitutions of captured text.</p> 1187*0e209d39SAndroid Build Coastguard Worker * 1188*0e209d39SAndroid Build Coastguard Worker * <p>A note on preflight computation of buffersize and error handling: 1189*0e209d39SAndroid Build Coastguard Worker * Calls to uregex_appendReplacement() and uregex_appendTail() are 1190*0e209d39SAndroid Build Coastguard Worker * designed to be chained, one after another, with the destination 1191*0e209d39SAndroid Build Coastguard Worker * buffer pointer and buffer capacity updated after each in preparation 1192*0e209d39SAndroid Build Coastguard Worker * to for the next. If the destination buffer is exhausted partway through such a 1193*0e209d39SAndroid Build Coastguard Worker * sequence, a U_BUFFER_OVERFLOW_ERROR status will be returned. Normal 1194*0e209d39SAndroid Build Coastguard Worker * ICU conventions are for a function to perform no action if it is 1195*0e209d39SAndroid Build Coastguard Worker * called with an error status, but for this one case, uregex_appendRepacement() 1196*0e209d39SAndroid Build Coastguard Worker * will operate normally so that buffer size computations will complete 1197*0e209d39SAndroid Build Coastguard Worker * correctly. 1198*0e209d39SAndroid Build Coastguard Worker * 1199*0e209d39SAndroid Build Coastguard Worker * <p>For simple, prepackaged, non-incremental find-and-replace 1200*0e209d39SAndroid Build Coastguard Worker * operations, see replaceFirst() or replaceAll().</p> 1201*0e209d39SAndroid Build Coastguard Worker * 1202*0e209d39SAndroid Build Coastguard Worker * @param regexp The regular expression object. 1203*0e209d39SAndroid Build Coastguard Worker * @param replacementText The string that will replace the matched portion of the 1204*0e209d39SAndroid Build Coastguard Worker * input string as it is copied to the destination buffer. 1205*0e209d39SAndroid Build Coastguard Worker * The replacement text may contain references ($1, for 1206*0e209d39SAndroid Build Coastguard Worker * example) to capture groups from the match. 1207*0e209d39SAndroid Build Coastguard Worker * @param replacementLength The length of the replacement text string, 1208*0e209d39SAndroid Build Coastguard Worker * or -1 if the string is NUL terminated. 1209*0e209d39SAndroid Build Coastguard Worker * @param destBuf The buffer into which the results of the 1210*0e209d39SAndroid Build Coastguard Worker * find-and-replace are placed. On return, this pointer 1211*0e209d39SAndroid Build Coastguard Worker * will be updated to refer to the beginning of the 1212*0e209d39SAndroid Build Coastguard Worker * unused portion of buffer, leaving it in position for 1213*0e209d39SAndroid Build Coastguard Worker * a subsequent call to this function. 1214*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the output buffer, On return, this 1215*0e209d39SAndroid Build Coastguard Worker * parameter will be updated to reflect the space remaining 1216*0e209d39SAndroid Build Coastguard Worker * unused in the output buffer. 1217*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1218*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string. In the event that 1219*0e209d39SAndroid Build Coastguard Worker * destCapacity is inadequate, the full length of the 1220*0e209d39SAndroid Build Coastguard Worker * untruncated output string is returned. 1221*0e209d39SAndroid Build Coastguard Worker * 1222*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 1223*0e209d39SAndroid Build Coastguard Worker * 1224*0e209d39SAndroid Build Coastguard Worker */ 1225*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1226*0e209d39SAndroid Build Coastguard Worker uregex_appendReplacement(URegularExpression *regexp, 1227*0e209d39SAndroid Build Coastguard Worker const UChar *replacementText, 1228*0e209d39SAndroid Build Coastguard Worker int32_t replacementLength, 1229*0e209d39SAndroid Build Coastguard Worker UChar **destBuf, 1230*0e209d39SAndroid Build Coastguard Worker int32_t *destCapacity, 1231*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1232*0e209d39SAndroid Build Coastguard Worker 1233*0e209d39SAndroid Build Coastguard Worker /** 1234*0e209d39SAndroid Build Coastguard Worker * Implements a replace operation intended to be used as part of an 1235*0e209d39SAndroid Build Coastguard Worker * incremental find-and-replace. 1236*0e209d39SAndroid Build Coastguard Worker * 1237*0e209d39SAndroid Build Coastguard Worker * <p>The input string, starting from the end of the previous match and ending at 1238*0e209d39SAndroid Build Coastguard Worker * the start of the current match, is appended to the destination string. Then the 1239*0e209d39SAndroid Build Coastguard Worker * replacement string is appended to the output string, 1240*0e209d39SAndroid Build Coastguard Worker * including handling any substitutions of captured text.</p> 1241*0e209d39SAndroid Build Coastguard Worker * 1242*0e209d39SAndroid Build Coastguard Worker * <p>For simple, prepackaged, non-incremental find-and-replace 1243*0e209d39SAndroid Build Coastguard Worker * operations, see replaceFirst() or replaceAll().</p> 1244*0e209d39SAndroid Build Coastguard Worker * 1245*0e209d39SAndroid Build Coastguard Worker * @param regexp The regular expression object. 1246*0e209d39SAndroid Build Coastguard Worker * @param replacementText The string that will replace the matched portion of the 1247*0e209d39SAndroid Build Coastguard Worker * input string as it is copied to the destination buffer. 1248*0e209d39SAndroid Build Coastguard Worker * The replacement text may contain references ($1, for 1249*0e209d39SAndroid Build Coastguard Worker * example) to capture groups from the match. 1250*0e209d39SAndroid Build Coastguard Worker * @param dest A mutable UText that will receive the result. Must not be NULL. 1251*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1252*0e209d39SAndroid Build Coastguard Worker * 1253*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1254*0e209d39SAndroid Build Coastguard Worker */ 1255*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1256*0e209d39SAndroid Build Coastguard Worker uregex_appendReplacementUText(URegularExpression *regexp, 1257*0e209d39SAndroid Build Coastguard Worker UText *replacementText, 1258*0e209d39SAndroid Build Coastguard Worker UText *dest, 1259*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1260*0e209d39SAndroid Build Coastguard Worker 1261*0e209d39SAndroid Build Coastguard Worker /** 1262*0e209d39SAndroid Build Coastguard Worker * As the final step in a find-and-replace operation, append the remainder 1263*0e209d39SAndroid Build Coastguard Worker * of the input string, starting at the position following the last match, 1264*0e209d39SAndroid Build Coastguard Worker * to the destination string. <code>uregex_appendTail()</code> is intended 1265*0e209d39SAndroid Build Coastguard Worker * to be invoked after one or more invocations of the 1266*0e209d39SAndroid Build Coastguard Worker * <code>uregex_appendReplacement()</code> function. 1267*0e209d39SAndroid Build Coastguard Worker * 1268*0e209d39SAndroid Build Coastguard Worker * @param regexp The regular expression object. This is needed to 1269*0e209d39SAndroid Build Coastguard Worker * obtain the input string and with the position 1270*0e209d39SAndroid Build Coastguard Worker * of the last match within it. 1271*0e209d39SAndroid Build Coastguard Worker * @param destBuf The buffer in which the results of the 1272*0e209d39SAndroid Build Coastguard Worker * find-and-replace are placed. On return, the pointer 1273*0e209d39SAndroid Build Coastguard Worker * will be updated to refer to the beginning of the 1274*0e209d39SAndroid Build Coastguard Worker * unused portion of buffer. 1275*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the output buffer, On return, this 1276*0e209d39SAndroid Build Coastguard Worker * value will be updated to reflect the space remaining 1277*0e209d39SAndroid Build Coastguard Worker * unused in the output buffer. 1278*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1279*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string. In the event that 1280*0e209d39SAndroid Build Coastguard Worker * destCapacity is inadequate, the full length of the 1281*0e209d39SAndroid Build Coastguard Worker * untruncated output string is returned. 1282*0e209d39SAndroid Build Coastguard Worker * 1283*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 1284*0e209d39SAndroid Build Coastguard Worker */ 1285*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1286*0e209d39SAndroid Build Coastguard Worker uregex_appendTail(URegularExpression *regexp, 1287*0e209d39SAndroid Build Coastguard Worker UChar **destBuf, 1288*0e209d39SAndroid Build Coastguard Worker int32_t *destCapacity, 1289*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1290*0e209d39SAndroid Build Coastguard Worker 1291*0e209d39SAndroid Build Coastguard Worker /** 1292*0e209d39SAndroid Build Coastguard Worker * As the final step in a find-and-replace operation, append the remainder 1293*0e209d39SAndroid Build Coastguard Worker * of the input string, starting at the position following the last match, 1294*0e209d39SAndroid Build Coastguard Worker * to the destination string. <code>uregex_appendTailUText()</code> is intended 1295*0e209d39SAndroid Build Coastguard Worker * to be invoked after one or more invocations of the 1296*0e209d39SAndroid Build Coastguard Worker * <code>uregex_appendReplacementUText()</code> function. 1297*0e209d39SAndroid Build Coastguard Worker * 1298*0e209d39SAndroid Build Coastguard Worker * @param regexp The regular expression object. This is needed to 1299*0e209d39SAndroid Build Coastguard Worker * obtain the input string and with the position 1300*0e209d39SAndroid Build Coastguard Worker * of the last match within it. 1301*0e209d39SAndroid Build Coastguard Worker * @param dest A mutable UText that will receive the result. Must not be NULL. 1302*0e209d39SAndroid Build Coastguard Worker * 1303*0e209d39SAndroid Build Coastguard Worker * @param status Error code 1304*0e209d39SAndroid Build Coastguard Worker * 1305*0e209d39SAndroid Build Coastguard Worker * @return The destination UText. 1306*0e209d39SAndroid Build Coastguard Worker * 1307*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1308*0e209d39SAndroid Build Coastguard Worker */ 1309*0e209d39SAndroid Build Coastguard Worker U_CAPI UText * U_EXPORT2 1310*0e209d39SAndroid Build Coastguard Worker uregex_appendTailUText(URegularExpression *regexp, 1311*0e209d39SAndroid Build Coastguard Worker UText *dest, 1312*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1313*0e209d39SAndroid Build Coastguard Worker 1314*0e209d39SAndroid Build Coastguard Worker /** 1315*0e209d39SAndroid Build Coastguard Worker * Split a string into fields. Somewhat like split() from Perl. 1316*0e209d39SAndroid Build Coastguard Worker * The pattern matches identify delimiters that separate the input 1317*0e209d39SAndroid Build Coastguard Worker * into fields. The input data between the matches becomes the 1318*0e209d39SAndroid Build Coastguard Worker * fields themselves. 1319*0e209d39SAndroid Build Coastguard Worker * 1320*0e209d39SAndroid Build Coastguard Worker * Each of the fields is copied from the input string to the destination 1321*0e209d39SAndroid Build Coastguard Worker * buffer, and NUL terminated. The position of each field within 1322*0e209d39SAndroid Build Coastguard Worker * the destination buffer is returned in the destFields array. 1323*0e209d39SAndroid Build Coastguard Worker * 1324*0e209d39SAndroid Build Coastguard Worker * If the delimiter pattern includes capture groups, the captured text will 1325*0e209d39SAndroid Build Coastguard Worker * also appear in the destination array of output strings, interspersed 1326*0e209d39SAndroid Build Coastguard Worker * with the fields. This is similar to Perl, but differs from Java, 1327*0e209d39SAndroid Build Coastguard Worker * which ignores the presence of capture groups in the pattern. 1328*0e209d39SAndroid Build Coastguard Worker * 1329*0e209d39SAndroid Build Coastguard Worker * Trailing empty fields will always be returned, assuming sufficient 1330*0e209d39SAndroid Build Coastguard Worker * destination capacity. This differs from the default behavior for Java 1331*0e209d39SAndroid Build Coastguard Worker * and Perl where trailing empty fields are not returned. 1332*0e209d39SAndroid Build Coastguard Worker * 1333*0e209d39SAndroid Build Coastguard Worker * The number of strings produced by the split operation is returned. 1334*0e209d39SAndroid Build Coastguard Worker * This count includes the strings from capture groups in the delimiter pattern. 1335*0e209d39SAndroid Build Coastguard Worker * This behavior differs from Java, which ignores capture groups. 1336*0e209d39SAndroid Build Coastguard Worker * 1337*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1338*0e209d39SAndroid Build Coastguard Worker * @param destBuf A (UChar *) buffer to receive the fields that 1339*0e209d39SAndroid Build Coastguard Worker * are extracted from the input string. These 1340*0e209d39SAndroid Build Coastguard Worker * field pointers will refer to positions within the 1341*0e209d39SAndroid Build Coastguard Worker * destination buffer supplied by the caller. Any 1342*0e209d39SAndroid Build Coastguard Worker * extra positions within the destFields array will be 1343*0e209d39SAndroid Build Coastguard Worker * set to NULL. 1344*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The capacity of the destBuf. 1345*0e209d39SAndroid Build Coastguard Worker * @param requiredCapacity The actual capacity required of the destBuf. 1346*0e209d39SAndroid Build Coastguard Worker * If destCapacity is too small, requiredCapacity will return 1347*0e209d39SAndroid Build Coastguard Worker * the total capacity required to hold all of the output, and 1348*0e209d39SAndroid Build Coastguard Worker * a U_BUFFER_OVERFLOW_ERROR will be returned. 1349*0e209d39SAndroid Build Coastguard Worker * @param destFields An array to be filled with the position of each 1350*0e209d39SAndroid Build Coastguard Worker * of the extracted fields within destBuf. 1351*0e209d39SAndroid Build Coastguard Worker * @param destFieldsCapacity The number of elements in the destFields array. 1352*0e209d39SAndroid Build Coastguard Worker * If the number of fields found is less than destFieldsCapacity, 1353*0e209d39SAndroid Build Coastguard Worker * the extra destFields elements are set to zero. 1354*0e209d39SAndroid Build Coastguard Worker * If destFieldsCapacity is too small, the trailing part of the 1355*0e209d39SAndroid Build Coastguard Worker * input, including any field delimiters, is treated as if it 1356*0e209d39SAndroid Build Coastguard Worker * were the last field - it is copied to the destBuf, and 1357*0e209d39SAndroid Build Coastguard Worker * its position is in the destBuf is stored in the last element 1358*0e209d39SAndroid Build Coastguard Worker * of destFields. This behavior mimics that of Perl. It is not 1359*0e209d39SAndroid Build Coastguard Worker * an error condition, and no error status is returned when all destField 1360*0e209d39SAndroid Build Coastguard Worker * positions are used. 1361*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1362*0e209d39SAndroid Build Coastguard Worker * @return The number of fields into which the input string was split. 1363*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 1364*0e209d39SAndroid Build Coastguard Worker */ 1365*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1366*0e209d39SAndroid Build Coastguard Worker uregex_split( URegularExpression *regexp, 1367*0e209d39SAndroid Build Coastguard Worker UChar *destBuf, 1368*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1369*0e209d39SAndroid Build Coastguard Worker int32_t *requiredCapacity, 1370*0e209d39SAndroid Build Coastguard Worker UChar *destFields[], 1371*0e209d39SAndroid Build Coastguard Worker int32_t destFieldsCapacity, 1372*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1373*0e209d39SAndroid Build Coastguard Worker 1374*0e209d39SAndroid Build Coastguard Worker /** 1375*0e209d39SAndroid Build Coastguard Worker * Split a string into fields. Somewhat like split() from Perl. 1376*0e209d39SAndroid Build Coastguard Worker * The pattern matches identify delimiters that separate the input 1377*0e209d39SAndroid Build Coastguard Worker * into fields. The input data between the matches becomes the 1378*0e209d39SAndroid Build Coastguard Worker * fields themselves. 1379*0e209d39SAndroid Build Coastguard Worker * <p> 1380*0e209d39SAndroid Build Coastguard Worker * The behavior of this function is not very closely aligned with uregex_split(); 1381*0e209d39SAndroid Build Coastguard Worker * instead, it is based on (and implemented directly on top of) the C++ split method. 1382*0e209d39SAndroid Build Coastguard Worker * 1383*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1384*0e209d39SAndroid Build Coastguard Worker * @param destFields An array of mutable UText structs to receive the results of the split. 1385*0e209d39SAndroid Build Coastguard Worker * If a field is NULL, a new UText is allocated to contain the results for 1386*0e209d39SAndroid Build Coastguard Worker * that field. This new UText is not guaranteed to be mutable. 1387*0e209d39SAndroid Build Coastguard Worker * @param destFieldsCapacity The number of elements in the destination array. 1388*0e209d39SAndroid Build Coastguard Worker * If the number of fields found is less than destCapacity, the 1389*0e209d39SAndroid Build Coastguard Worker * extra strings in the destination array are not altered. 1390*0e209d39SAndroid Build Coastguard Worker * If the number of destination strings is less than the number 1391*0e209d39SAndroid Build Coastguard Worker * of fields, the trailing part of the input string, including any 1392*0e209d39SAndroid Build Coastguard Worker * field delimiters, is placed in the last destination string. 1393*0e209d39SAndroid Build Coastguard Worker * This behavior mimics that of Perl. It is not an error condition, and no 1394*0e209d39SAndroid Build Coastguard Worker * error status is returned when all destField positions are used. 1395*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1396*0e209d39SAndroid Build Coastguard Worker * @return The number of fields into which the input string was split. 1397*0e209d39SAndroid Build Coastguard Worker * 1398*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1399*0e209d39SAndroid Build Coastguard Worker */ 1400*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1401*0e209d39SAndroid Build Coastguard Worker uregex_splitUText(URegularExpression *regexp, 1402*0e209d39SAndroid Build Coastguard Worker UText *destFields[], 1403*0e209d39SAndroid Build Coastguard Worker int32_t destFieldsCapacity, 1404*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1405*0e209d39SAndroid Build Coastguard Worker 1406*0e209d39SAndroid Build Coastguard Worker /** 1407*0e209d39SAndroid Build Coastguard Worker * Set a processing time limit for match operations with this URegularExpression. 1408*0e209d39SAndroid Build Coastguard Worker * 1409*0e209d39SAndroid Build Coastguard Worker * Some patterns, when matching certain strings, can run in exponential time. 1410*0e209d39SAndroid Build Coastguard Worker * For practical purposes, the match operation may appear to be in an 1411*0e209d39SAndroid Build Coastguard Worker * infinite loop. 1412*0e209d39SAndroid Build Coastguard Worker * When a limit is set a match operation will fail with an error if the 1413*0e209d39SAndroid Build Coastguard Worker * limit is exceeded. 1414*0e209d39SAndroid Build Coastguard Worker * <p> 1415*0e209d39SAndroid Build Coastguard Worker * The units of the limit are steps of the match engine. 1416*0e209d39SAndroid Build Coastguard Worker * Correspondence with actual processor time will depend on the speed 1417*0e209d39SAndroid Build Coastguard Worker * of the processor and the details of the specific pattern, but will 1418*0e209d39SAndroid Build Coastguard Worker * typically be on the order of milliseconds. 1419*0e209d39SAndroid Build Coastguard Worker * <p> 1420*0e209d39SAndroid Build Coastguard Worker * By default, the matching time is not limited. 1421*0e209d39SAndroid Build Coastguard Worker * <p> 1422*0e209d39SAndroid Build Coastguard Worker * 1423*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1424*0e209d39SAndroid Build Coastguard Worker * @param limit The limit value, or 0 for no limit. 1425*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1426*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1427*0e209d39SAndroid Build Coastguard Worker */ 1428*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1429*0e209d39SAndroid Build Coastguard Worker uregex_setTimeLimit(URegularExpression *regexp, 1430*0e209d39SAndroid Build Coastguard Worker int32_t limit, 1431*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1432*0e209d39SAndroid Build Coastguard Worker 1433*0e209d39SAndroid Build Coastguard Worker /** 1434*0e209d39SAndroid Build Coastguard Worker * Get the time limit for for matches with this URegularExpression. 1435*0e209d39SAndroid Build Coastguard Worker * A return value of zero indicates that there is no limit. 1436*0e209d39SAndroid Build Coastguard Worker * 1437*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1438*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1439*0e209d39SAndroid Build Coastguard Worker * @return the maximum allowed time for a match, in units of processing steps. 1440*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1441*0e209d39SAndroid Build Coastguard Worker */ 1442*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1443*0e209d39SAndroid Build Coastguard Worker uregex_getTimeLimit(const URegularExpression *regexp, 1444*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1445*0e209d39SAndroid Build Coastguard Worker 1446*0e209d39SAndroid Build Coastguard Worker /** 1447*0e209d39SAndroid Build Coastguard Worker * Set the amount of heap storage available for use by the match backtracking stack. 1448*0e209d39SAndroid Build Coastguard Worker * <p> 1449*0e209d39SAndroid Build Coastguard Worker * ICU uses a backtracking regular expression engine, with the backtrack stack 1450*0e209d39SAndroid Build Coastguard Worker * maintained on the heap. This function sets the limit to the amount of memory 1451*0e209d39SAndroid Build Coastguard Worker * that can be used for this purpose. A backtracking stack overflow will 1452*0e209d39SAndroid Build Coastguard Worker * result in an error from the match operation that caused it. 1453*0e209d39SAndroid Build Coastguard Worker * <p> 1454*0e209d39SAndroid Build Coastguard Worker * A limit is desirable because a malicious or poorly designed pattern can use 1455*0e209d39SAndroid Build Coastguard Worker * excessive memory, potentially crashing the process. A limit is enabled 1456*0e209d39SAndroid Build Coastguard Worker * by default. 1457*0e209d39SAndroid Build Coastguard Worker * <p> 1458*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1459*0e209d39SAndroid Build Coastguard Worker * @param limit The maximum size, in bytes, of the matching backtrack stack. 1460*0e209d39SAndroid Build Coastguard Worker * A value of zero means no limit. 1461*0e209d39SAndroid Build Coastguard Worker * The limit must be greater than or equal to zero. 1462*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1463*0e209d39SAndroid Build Coastguard Worker * 1464*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1465*0e209d39SAndroid Build Coastguard Worker */ 1466*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1467*0e209d39SAndroid Build Coastguard Worker uregex_setStackLimit(URegularExpression *regexp, 1468*0e209d39SAndroid Build Coastguard Worker int32_t limit, 1469*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1470*0e209d39SAndroid Build Coastguard Worker 1471*0e209d39SAndroid Build Coastguard Worker /** 1472*0e209d39SAndroid Build Coastguard Worker * Get the size of the heap storage available for use by the back tracking stack. 1473*0e209d39SAndroid Build Coastguard Worker * 1474*0e209d39SAndroid Build Coastguard Worker * @return the maximum backtracking stack size, in bytes, or zero if the 1475*0e209d39SAndroid Build Coastguard Worker * stack size is unlimited. 1476*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1477*0e209d39SAndroid Build Coastguard Worker */ 1478*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1479*0e209d39SAndroid Build Coastguard Worker uregex_getStackLimit(const URegularExpression *regexp, 1480*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1481*0e209d39SAndroid Build Coastguard Worker 1482*0e209d39SAndroid Build Coastguard Worker 1483*0e209d39SAndroid Build Coastguard Worker /** 1484*0e209d39SAndroid Build Coastguard Worker * Function pointer for a regular expression matching callback function. 1485*0e209d39SAndroid Build Coastguard Worker * When set, a callback function will be called periodically during matching 1486*0e209d39SAndroid Build Coastguard Worker * operations. If the call back function returns false, the matching 1487*0e209d39SAndroid Build Coastguard Worker * operation will be terminated early. 1488*0e209d39SAndroid Build Coastguard Worker * 1489*0e209d39SAndroid Build Coastguard Worker * Note: the callback function must not call other functions on this 1490*0e209d39SAndroid Build Coastguard Worker * URegularExpression. 1491*0e209d39SAndroid Build Coastguard Worker * 1492*0e209d39SAndroid Build Coastguard Worker * @param context context pointer. The callback function will be invoked 1493*0e209d39SAndroid Build Coastguard Worker * with the context specified at the time that 1494*0e209d39SAndroid Build Coastguard Worker * uregex_setMatchCallback() is called. 1495*0e209d39SAndroid Build Coastguard Worker * @param steps the accumulated processing time, in match steps, 1496*0e209d39SAndroid Build Coastguard Worker * for this matching operation. 1497*0e209d39SAndroid Build Coastguard Worker * @return true to continue the matching operation. 1498*0e209d39SAndroid Build Coastguard Worker * false to terminate the matching operation. 1499*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1500*0e209d39SAndroid Build Coastguard Worker */ 1501*0e209d39SAndroid Build Coastguard Worker U_CDECL_BEGIN 1502*0e209d39SAndroid Build Coastguard Worker typedef UBool U_CALLCONV URegexMatchCallback ( 1503*0e209d39SAndroid Build Coastguard Worker const void *context, 1504*0e209d39SAndroid Build Coastguard Worker int32_t steps); 1505*0e209d39SAndroid Build Coastguard Worker U_CDECL_END 1506*0e209d39SAndroid Build Coastguard Worker 1507*0e209d39SAndroid Build Coastguard Worker /** 1508*0e209d39SAndroid Build Coastguard Worker * Set a callback function for this URegularExpression. 1509*0e209d39SAndroid Build Coastguard Worker * During matching operations the function will be called periodically, 1510*0e209d39SAndroid Build Coastguard Worker * giving the application the opportunity to terminate a long-running 1511*0e209d39SAndroid Build Coastguard Worker * match. 1512*0e209d39SAndroid Build Coastguard Worker * 1513*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1514*0e209d39SAndroid Build Coastguard Worker * @param callback A pointer to the user-supplied callback function. 1515*0e209d39SAndroid Build Coastguard Worker * @param context User context pointer. The value supplied at the 1516*0e209d39SAndroid Build Coastguard Worker * time the callback function is set will be saved 1517*0e209d39SAndroid Build Coastguard Worker * and passed to the callback each time that it is called. 1518*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1519*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1520*0e209d39SAndroid Build Coastguard Worker */ 1521*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1522*0e209d39SAndroid Build Coastguard Worker uregex_setMatchCallback(URegularExpression *regexp, 1523*0e209d39SAndroid Build Coastguard Worker URegexMatchCallback *callback, 1524*0e209d39SAndroid Build Coastguard Worker const void *context, 1525*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1526*0e209d39SAndroid Build Coastguard Worker 1527*0e209d39SAndroid Build Coastguard Worker 1528*0e209d39SAndroid Build Coastguard Worker /** 1529*0e209d39SAndroid Build Coastguard Worker * Get the callback function for this URegularExpression. 1530*0e209d39SAndroid Build Coastguard Worker * 1531*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1532*0e209d39SAndroid Build Coastguard Worker * @param callback Out parameter, receives a pointer to the user-supplied 1533*0e209d39SAndroid Build Coastguard Worker * callback function. 1534*0e209d39SAndroid Build Coastguard Worker * @param context Out parameter, receives the user context pointer that 1535*0e209d39SAndroid Build Coastguard Worker * was set when uregex_setMatchCallback() was called. 1536*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1537*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 1538*0e209d39SAndroid Build Coastguard Worker */ 1539*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1540*0e209d39SAndroid Build Coastguard Worker uregex_getMatchCallback(const URegularExpression *regexp, 1541*0e209d39SAndroid Build Coastguard Worker URegexMatchCallback **callback, 1542*0e209d39SAndroid Build Coastguard Worker const void **context, 1543*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1544*0e209d39SAndroid Build Coastguard Worker 1545*0e209d39SAndroid Build Coastguard Worker /** 1546*0e209d39SAndroid Build Coastguard Worker * Function pointer for a regular expression find callback function. 1547*0e209d39SAndroid Build Coastguard Worker * 1548*0e209d39SAndroid Build Coastguard Worker * When set, a callback function will be called during a find operation 1549*0e209d39SAndroid Build Coastguard Worker * and for operations that depend on find, such as findNext, split and some replace 1550*0e209d39SAndroid Build Coastguard Worker * operations like replaceFirst. 1551*0e209d39SAndroid Build Coastguard Worker * The callback will usually be called after each attempt at a match, but this is not a 1552*0e209d39SAndroid Build Coastguard Worker * guarantee that the callback will be invoked at each character. For finds where the 1553*0e209d39SAndroid Build Coastguard Worker * match engine is invoked at each character, this may be close to true, but less likely 1554*0e209d39SAndroid Build Coastguard Worker * for more optimized loops where the pattern is known to only start, and the match 1555*0e209d39SAndroid Build Coastguard Worker * engine invoked, at certain characters. 1556*0e209d39SAndroid Build Coastguard Worker * When invoked, this callback will specify the index at which a match operation is about 1557*0e209d39SAndroid Build Coastguard Worker * to be attempted, giving the application the opportunity to terminate a long-running 1558*0e209d39SAndroid Build Coastguard Worker * find operation. 1559*0e209d39SAndroid Build Coastguard Worker * 1560*0e209d39SAndroid Build Coastguard Worker * If the call back function returns false, the find operation will be terminated early. 1561*0e209d39SAndroid Build Coastguard Worker * 1562*0e209d39SAndroid Build Coastguard Worker * Note: the callback function must not call other functions on this 1563*0e209d39SAndroid Build Coastguard Worker * URegularExpression 1564*0e209d39SAndroid Build Coastguard Worker * 1565*0e209d39SAndroid Build Coastguard Worker * @param context context pointer. The callback function will be invoked 1566*0e209d39SAndroid Build Coastguard Worker * with the context specified at the time that 1567*0e209d39SAndroid Build Coastguard Worker * uregex_setFindProgressCallback() is called. 1568*0e209d39SAndroid Build Coastguard Worker * @param matchIndex the next index at which a match attempt will be attempted for this 1569*0e209d39SAndroid Build Coastguard Worker * find operation. If this callback interrupts the search, this is the 1570*0e209d39SAndroid Build Coastguard Worker * index at which a find/findNext operation may be re-initiated. 1571*0e209d39SAndroid Build Coastguard Worker * @return true to continue the matching operation. 1572*0e209d39SAndroid Build Coastguard Worker * false to terminate the matching operation. 1573*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1574*0e209d39SAndroid Build Coastguard Worker */ 1575*0e209d39SAndroid Build Coastguard Worker U_CDECL_BEGIN 1576*0e209d39SAndroid Build Coastguard Worker typedef UBool U_CALLCONV URegexFindProgressCallback ( 1577*0e209d39SAndroid Build Coastguard Worker const void *context, 1578*0e209d39SAndroid Build Coastguard Worker int64_t matchIndex); 1579*0e209d39SAndroid Build Coastguard Worker U_CDECL_END 1580*0e209d39SAndroid Build Coastguard Worker 1581*0e209d39SAndroid Build Coastguard Worker 1582*0e209d39SAndroid Build Coastguard Worker /** 1583*0e209d39SAndroid Build Coastguard Worker * Set the find progress callback function for this URegularExpression. 1584*0e209d39SAndroid Build Coastguard Worker * 1585*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1586*0e209d39SAndroid Build Coastguard Worker * @param callback A pointer to the user-supplied callback function. 1587*0e209d39SAndroid Build Coastguard Worker * @param context User context pointer. The value supplied at the 1588*0e209d39SAndroid Build Coastguard Worker * time the callback function is set will be saved 1589*0e209d39SAndroid Build Coastguard Worker * and passed to the callback each time that it is called. 1590*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1591*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1592*0e209d39SAndroid Build Coastguard Worker */ 1593*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1594*0e209d39SAndroid Build Coastguard Worker uregex_setFindProgressCallback(URegularExpression *regexp, 1595*0e209d39SAndroid Build Coastguard Worker URegexFindProgressCallback *callback, 1596*0e209d39SAndroid Build Coastguard Worker const void *context, 1597*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1598*0e209d39SAndroid Build Coastguard Worker 1599*0e209d39SAndroid Build Coastguard Worker /** 1600*0e209d39SAndroid Build Coastguard Worker * Get the find progress callback function for this URegularExpression. 1601*0e209d39SAndroid Build Coastguard Worker * 1602*0e209d39SAndroid Build Coastguard Worker * @param regexp The compiled regular expression. 1603*0e209d39SAndroid Build Coastguard Worker * @param callback Out parameter, receives a pointer to the user-supplied 1604*0e209d39SAndroid Build Coastguard Worker * callback function. 1605*0e209d39SAndroid Build Coastguard Worker * @param context Out parameter, receives the user context pointer that 1606*0e209d39SAndroid Build Coastguard Worker * was set when uregex_setFindProgressCallback() was called. 1607*0e209d39SAndroid Build Coastguard Worker * @param status A reference to a UErrorCode to receive any errors. 1608*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1609*0e209d39SAndroid Build Coastguard Worker */ 1610*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1611*0e209d39SAndroid Build Coastguard Worker uregex_getFindProgressCallback(const URegularExpression *regexp, 1612*0e209d39SAndroid Build Coastguard Worker URegexFindProgressCallback **callback, 1613*0e209d39SAndroid Build Coastguard Worker const void **context, 1614*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1615*0e209d39SAndroid Build Coastguard Worker 1616*0e209d39SAndroid Build Coastguard Worker #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ 1617*0e209d39SAndroid Build Coastguard Worker #endif /* UREGEX_H */ 1618