+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
-* Copyright (C) 2004-2012, International Business Machines
+* Copyright (C) 2004-2016, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: uregex.h
-* encoding: US-ASCII
+* encoding: UTF-8
* indentation:4
*
* created on: 2004mar09
Not implemented yet, just a placeholder, hence draft.
@draft ICU 2.4 */
UREGEX_CANON_EQ = 128,
-#endif
+#endif /* U_HIDE_DRAFT_API */
/** Enable case insensitive matching. @stable ICU 2.4 */
UREGEX_CASE_INSENSITIVE = 2,
*
* @stable ICU 4.6
*/
-U_DRAFT URegularExpression * U_EXPORT2
+U_STABLE URegularExpression * U_EXPORT2
uregex_openUText(UText *pattern,
uint32_t flags,
UParseError *pe,
U_NAMESPACE_END
-#endif
+#endif // U_SHOW_CPLUSPLUS_API
/**
* Make a copy of a compiled regular expression. Cloning a regular
*
* @stable ICU 4.6
*/
-U_DRAFT UText * U_EXPORT2
+U_STABLE UText * U_EXPORT2
uregex_patternUText(const URegularExpression *regexp,
UErrorCode *status);
*
* @stable ICU 4.6
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
uregex_setUText(URegularExpression *regexp,
UText *text,
UErrorCode *status);
*
* @stable ICU 4.6
*/
-U_DRAFT UText * U_EXPORT2
+U_STABLE UText * U_EXPORT2
uregex_getUText(URegularExpression *regexp,
UText *dest,
UErrorCode *status);
* @param text The new (moved) text string.
* @param status Receives errors detected by this function.
*
- * @stable ICU 4.8
+ * @stable ICU 4.8
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
uregex_refreshUText(URegularExpression *regexp,
UText *text,
UErrorCode *status);
* @return TRUE if there is a match
* @stable ICU 4.6
*/
-U_DRAFT UBool U_EXPORT2
+U_STABLE UBool U_EXPORT2
uregex_matches64(URegularExpression *regexp,
int64_t startIndex,
UErrorCode *status);
*
* <p>If the match succeeds then more information can be obtained via the
* <code>uregexp_start()</code>, <code>uregexp_end()</code>,
- * and <code>uregexp_group()</code> functions.</p>
+ * and <code>uregex_group()</code> functions.</p>
*
* @param regexp The compiled regular expression.
* @param startIndex The input string (native) index at which to begin matching, or
*
* <p>If the match succeeds then more information can be obtained via the
* <code>uregexp_start()</code>, <code>uregexp_end()</code>,
- * and <code>uregexp_group()</code> functions.</p>
+ * and <code>uregex_group()</code> functions.</p>
*
* @param regexp The compiled regular expression.
* @param startIndex The input string (native) index at which to begin matching, or
* @return TRUE if there is a match.
* @stable ICU 4.6
*/
-U_DRAFT UBool U_EXPORT2
+U_STABLE UBool U_EXPORT2
uregex_lookingAt64(URegularExpression *regexp,
int64_t startIndex,
UErrorCode *status);
* @return TRUE if a match is found.
* @stable ICU 4.6
*/
-U_DRAFT UBool U_EXPORT2
+U_STABLE UBool U_EXPORT2
uregex_find64(URegularExpression *regexp,
int64_t startIndex,
UErrorCode *status);
uregex_groupCount(URegularExpression *regexp,
UErrorCode *status);
+/**
+ * Get the group number corresponding to a named capture group.
+ * The returned number can be used with any function that access
+ * capture groups by number.
+ *
+ * The function returns an error status if the specified name does not
+ * appear in the pattern.
+ *
+ * @param regexp The compiled regular expression.
+ * @param groupName The capture group name.
+ * @param nameLength The length of the name, or -1 if the name is a
+ * nul-terminated string.
+ * @param status A pointer to a UErrorCode to receive any errors.
+ *
+ * @stable ICU 55
+ */
+U_STABLE int32_t U_EXPORT2
+uregex_groupNumberFromName(URegularExpression *regexp,
+ const UChar *groupName,
+ int32_t nameLength,
+ UErrorCode *status);
+
+
+/**
+ * Get the group number corresponding to a named capture group.
+ * The returned number can be used with any function that access
+ * capture groups by number.
+ *
+ * The function returns an error status if the specified name does not
+ * appear in the pattern.
+ *
+ * @param regexp The compiled regular expression.
+ * @param groupName The capture group name,
+ * platform invariant characters only.
+ * @param nameLength The length of the name, or -1 if the name is
+ * nul-terminated.
+ * @param status A pointer to a UErrorCode to receive any errors.
+ *
+ * @stable ICU 55
+ */
+U_STABLE int32_t U_EXPORT2
+uregex_groupNumberFromCName(URegularExpression *regexp,
+ const char *groupName,
+ int32_t nameLength,
+ UErrorCode *status);
+
/** Extract the string for the specified matching expression or subexpression.
* Group #0 is the complete string of matched text.
* Group #1 is the text matched by the first set of capturing parentheses.
int32_t destCapacity,
UErrorCode *status);
-/** Returns a shallow immutable clone of the entire input string. The returned UText current native index
- * is set to the beginning of the requested capture group. The capture group length is also
+/** Returns a shallow immutable clone of the entire input string with the current index set
+ * to the beginning of the requested capture group. The capture group length is also
* returned via groupLength.
* Group #0 is the complete string of matched text.
* Group #1 is the text matched by the first set of capturing parentheses.
* @param dest A mutable UText in which to store the current input.
* If NULL, a new UText will be created as an immutable shallow clone
* of the entire input string.
- * @param groupLength The group length of the desired capture group.
+ * @param groupLength The group length of the desired capture group. Output parameter.
* @param status A reference to a UErrorCode to receive any errors.
* @return The subject text currently associated with this regular expression.
* If a pre-allocated UText was provided, it will always be used and returned.
*
* @stable ICU 4.6
*/
-U_DRAFT UText * U_EXPORT2
+U_STABLE UText * U_EXPORT2
uregex_groupUText(URegularExpression *regexp,
int32_t groupNum,
UText *dest,
int64_t *groupLength,
UErrorCode *status);
-#ifndef U_HIDE_INTERNAL_API
-/** Extract the string for the specified matching expression or subexpression.
- * Group #0 is the complete string of matched text.
- * Group #1 is the text matched by the first set of capturing parentheses.
- *
- * @param regexp The compiled regular expression.
- * @param groupNum The capture group to extract. Group 0 is the complete
- * match. The value of this parameter must be
- * less than or equal to the number of capture groups in
- * the pattern.
- * @param dest Mutable UText to receive the matching string data.
- * If NULL, a new UText will be created (which may not be mutable).
- * @param status A reference to a UErrorCode to receive any errors.
- * @return The matching string data. If a pre-allocated UText was provided,
- * it will always be used and returned.
- *
- * @internal ICU 4.4 technology preview
- */
-U_INTERNAL UText * U_EXPORT2
-uregex_groupUTextDeep(URegularExpression *regexp,
- int32_t groupNum,
- UText *dest,
- UErrorCode *status);
-#endif /* U_HIDE_INTERNAL_API */
-
/**
* Returns the index in the input string of the start of the text matched by the
* specified capture group during the previous match operation. Return -1 if
* by the specified group.
* @stable ICU 4.6
*/
-U_DRAFT int64_t U_EXPORT2
+U_STABLE int64_t U_EXPORT2
uregex_start64(URegularExpression *regexp,
int32_t groupNum,
UErrorCode *status);
* @return the (native) index of the position following the last matched character.
* @stable ICU 4.6
*/
-U_DRAFT int64_t U_EXPORT2
+U_STABLE int64_t U_EXPORT2
uregex_end64(URegularExpression *regexp,
int32_t groupNum,
UErrorCode *status);
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
uregex_reset64(URegularExpression *regexp,
int64_t index,
UErrorCode *status);
* @param status A pointer to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
uregex_setRegion64(URegularExpression *regexp,
int64_t regionStart,
int64_t regionLimit,
* @param status A pointer to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
uregex_setRegionAndStart(URegularExpression *regexp,
int64_t regionStart,
int64_t regionLimit,
* @return The starting (native) index of this matcher's region.
* @stable ICU 4.6
*/
-U_DRAFT int64_t U_EXPORT2
+U_STABLE int64_t U_EXPORT2
uregex_regionStart64(const URegularExpression *regexp,
UErrorCode *status);
* @return The ending point (native) of this matcher's region.
* @stable ICU 4.6
*/
-U_DRAFT int64_t U_EXPORT2
+U_STABLE int64_t U_EXPORT2
uregex_regionEnd64(const URegularExpression *regexp,
UErrorCode *status);
*
* @stable ICU 4.6
*/
-U_DRAFT UText * U_EXPORT2
+U_STABLE UText * U_EXPORT2
uregex_replaceAllUText(URegularExpression *regexp,
UText *replacement,
UText *dest,
*
* @stable ICU 4.6
*/
-U_DRAFT UText * U_EXPORT2
+U_STABLE UText * U_EXPORT2
uregex_replaceFirstUText(URegularExpression *regexp,
UText *replacement,
UText *dest,
*
* @stable ICU 4.6
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
uregex_appendReplacementUText(URegularExpression *regexp,
UText *replacementText,
UText *dest,
*
* @stable ICU 4.6
*/
-U_DRAFT UText * U_EXPORT2
+U_STABLE UText * U_EXPORT2
uregex_appendTailUText(URegularExpression *regexp,
UText *dest,
UErrorCode *status);
*
* @stable ICU 4.6
*/
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
uregex_splitUText(URegularExpression *regexp,
UText *destFields[],
int32_t destFieldsCapacity,
* <p>
* @param regexp The compiled regular expression.
* @param limit The maximum size, in bytes, of the matching backtrack stack.
- * A value of -1 means no limit.
- * The limit must be greater than zero, or -1.
+ * A value of zero means no limit.
+ * The limit must be greater than or equal to zero.
* @param status A reference to a UErrorCode to receive any errors.
*
* @stable ICU 4.0
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
uregex_setFindProgressCallback(URegularExpression *regexp,
URegexFindProgressCallback *callback,
const void *context,
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
uregex_getFindProgressCallback(const URegularExpression *regexp,
URegexFindProgressCallback **callback,
const void **context,