ICU 50.2 50.2
uregex.h
Go to the documentation of this file.
1/*
2**********************************************************************
3* Copyright (C) 2004-2012, International Business Machines
4* Corporation and others. All Rights Reserved.
5**********************************************************************
6* file name: uregex.h
7* encoding: US-ASCII
8* indentation:4
9*
10* created on: 2004mar09
11* created by: Andy Heninger
12*
13* ICU Regular Expressions, API for C
14*/
15
22
23#ifndef UREGEX_H
24#define UREGEX_H
25
26#include "unicode/utext.h"
27#include "unicode/utypes.h"
28
29#if !UCONFIG_NO_REGULAR_EXPRESSIONS
30
32#include "unicode/parseerr.h"
33
41
42
47typedef enum URegexpFlag{
48
49#ifndef U_HIDE_DRAFT_API
54#endif
57
60
64
76
82
89
98
107
109
133uregex_open( const UChar *pattern,
134 int32_t patternLength,
135 uint32_t flags,
136 UParseError *pe,
137 UErrorCode *status);
138
164 uint32_t flags,
165 UParseError *pe,
166 UErrorCode *status);
167
191#if !UCONFIG_NO_CONVERSION
193uregex_openC( const char *pattern,
194 uint32_t flags,
195 UParseError *pe,
196 UErrorCode *status);
197#endif
198
199
200
208U_STABLE void U_EXPORT2
210
211#if U_SHOW_CPLUSPLUS_API
212
214
225
227
228#endif
229
248U_STABLE URegularExpression * U_EXPORT2
250
268U_STABLE const UChar * U_EXPORT2
270 int32_t *patLength,
271 UErrorCode *status);
272
284U_STABLE UText * U_EXPORT2
286 UErrorCode *status);
287
296U_STABLE int32_t U_EXPORT2
298 UErrorCode *status);
299
300
321U_STABLE void U_EXPORT2
323 const UChar *text,
324 int32_t textLength,
325 UErrorCode *status);
326
327
344U_STABLE void U_EXPORT2
346 UText *text,
347 UErrorCode *status);
348
369U_STABLE const UChar * U_EXPORT2
371 int32_t *textLength,
372 UErrorCode *status);
373
390U_STABLE UText * U_EXPORT2
392 UText *dest,
393 UErrorCode *status);
394
420U_STABLE void U_EXPORT2
422 UText *text,
423 UErrorCode *status);
424
445U_STABLE UBool U_EXPORT2
447 int32_t startIndex,
448 UErrorCode *status);
449
471U_STABLE UBool U_EXPORT2
473 int64_t startIndex,
474 UErrorCode *status);
475
499U_STABLE UBool U_EXPORT2
501 int32_t startIndex,
502 UErrorCode *status);
503
528U_STABLE UBool U_EXPORT2
530 int64_t startIndex,
531 UErrorCode *status);
532
552U_STABLE UBool U_EXPORT2
554 int32_t startIndex,
555 UErrorCode *status);
556
577U_STABLE UBool U_EXPORT2
579 int64_t startIndex,
580 UErrorCode *status);
581
595U_STABLE UBool U_EXPORT2
597 UErrorCode *status);
598
606U_STABLE int32_t U_EXPORT2
608 UErrorCode *status);
609
626U_STABLE int32_t U_EXPORT2
628 int32_t groupNum,
629 UChar *dest,
630 int32_t destCapacity,
631 UErrorCode *status);
632
655U_STABLE UText * U_EXPORT2
657 int32_t groupNum,
658 UText *dest,
659 int64_t *groupLength,
660 UErrorCode *status);
661
662#ifndef U_HIDE_INTERNAL_API
680U_INTERNAL UText * U_EXPORT2
682 int32_t groupNum,
683 UText *dest,
684 UErrorCode *status);
685#endif /* U_HIDE_INTERNAL_API */
686
701U_STABLE int32_t U_EXPORT2
703 int32_t groupNum,
704 UErrorCode *status);
705
721U_STABLE int64_t U_EXPORT2
723 int32_t groupNum,
724 UErrorCode *status);
725
739U_STABLE int32_t U_EXPORT2
741 int32_t groupNum,
742 UErrorCode *status);
743
758U_STABLE int64_t U_EXPORT2
760 int32_t groupNum,
761 UErrorCode *status);
762
776U_STABLE void U_EXPORT2
778 int32_t index,
779 UErrorCode *status);
780
795U_STABLE void U_EXPORT2
797 int64_t index,
798 UErrorCode *status);
799
820U_STABLE void U_EXPORT2
822 int32_t regionStart,
823 int32_t regionLimit,
824 UErrorCode *status);
825
847U_STABLE void U_EXPORT2
849 int64_t regionStart,
850 int64_t regionLimit,
851 UErrorCode *status);
852
867U_STABLE void U_EXPORT2
869 int64_t regionStart,
870 int64_t regionLimit,
871 int64_t startIndex,
872 UErrorCode *status);
873
883U_STABLE int32_t U_EXPORT2
885 UErrorCode *status);
886
897U_STABLE int64_t U_EXPORT2
899 UErrorCode *status);
900
911U_STABLE int32_t U_EXPORT2
913 UErrorCode *status);
914
926U_STABLE int64_t U_EXPORT2
928 UErrorCode *status);
929
940U_STABLE UBool U_EXPORT2
942 UErrorCode *status);
943
944
964U_STABLE void U_EXPORT2
966 UBool b,
967 UErrorCode *status);
968
969
979U_STABLE UBool U_EXPORT2
981 UErrorCode *status);
982
983
997U_STABLE void U_EXPORT2
999 UBool b,
1000 UErrorCode *status);
1001
1012U_STABLE UBool U_EXPORT2
1014 UErrorCode *status);
1015
1027U_STABLE UBool U_EXPORT2
1029 UErrorCode *status);
1030
1031
1032
1033
1034
1059U_STABLE int32_t U_EXPORT2
1061 const UChar *replacementText,
1062 int32_t replacementLength,
1063 UChar *destBuf,
1064 int32_t destCapacity,
1065 UErrorCode *status);
1066
1088U_STABLE UText * U_EXPORT2
1090 UText *replacement,
1091 UText *dest,
1092 UErrorCode *status);
1093
1118U_STABLE int32_t U_EXPORT2
1120 const UChar *replacementText,
1121 int32_t replacementLength,
1122 UChar *destBuf,
1123 int32_t destCapacity,
1124 UErrorCode *status);
1125
1147U_STABLE UText * U_EXPORT2
1149 UText *replacement,
1150 UText *dest,
1151 UErrorCode *status);
1152
1199U_STABLE int32_t U_EXPORT2
1201 const UChar *replacementText,
1202 int32_t replacementLength,
1203 UChar **destBuf,
1204 int32_t *destCapacity,
1205 UErrorCode *status);
1206
1229U_STABLE void U_EXPORT2
1231 UText *replacementText,
1232 UText *dest,
1233 UErrorCode *status);
1234
1259U_STABLE int32_t U_EXPORT2
1261 UChar **destBuf,
1262 int32_t *destCapacity,
1263 UErrorCode *status);
1264
1283U_STABLE UText * U_EXPORT2
1285 UText *dest,
1286 UErrorCode *status);
1287
1339U_STABLE int32_t U_EXPORT2
1341 UChar *destBuf,
1342 int32_t destCapacity,
1343 int32_t *requiredCapacity,
1344 UChar *destFields[],
1345 int32_t destFieldsCapacity,
1346 UErrorCode *status);
1347
1374U_STABLE int32_t U_EXPORT2
1376 UText *destFields[],
1377 int32_t destFieldsCapacity,
1378 UErrorCode *status);
1379
1402U_STABLE void U_EXPORT2
1404 int32_t limit,
1405 UErrorCode *status);
1406
1416U_STABLE int32_t U_EXPORT2
1418 UErrorCode *status);
1419
1440U_STABLE void U_EXPORT2
1442 int32_t limit,
1443 UErrorCode *status);
1444
1452U_STABLE int32_t U_EXPORT2
1454 UErrorCode *status);
1455
1456
1477 const void *context,
1478 int32_t steps);
1480
1495U_STABLE void U_EXPORT2
1497 URegexMatchCallback *callback,
1498 const void *context,
1499 UErrorCode *status);
1500
1501
1513U_STABLE void U_EXPORT2
1515 URegexMatchCallback **callback,
1516 const void **context,
1517 UErrorCode *status);
1518
1551 const void *context,
1552 int64_t matchIndex);
1554
1555
1567U_STABLE void U_EXPORT2
1570 const void *context,
1571 UErrorCode *status);
1572
1584U_STABLE void U_EXPORT2
1586 URegexFindProgressCallback **callback,
1587 const void **context,
1588 UErrorCode *status);
1589
1590#endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */
1591#endif /* UREGEX_H */
"Smart pointer" class, closes a URegularExpression via uregex_close().
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
C API: Parse Error Information.
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition platform.h:751
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:56
UText struct.
Definition utext.h:1343
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition umachine.h:117
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition umachine.h:83
int8_t UBool
The ICU boolean type.
Definition umachine.h:200
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition umachine.h:82
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition umachine.h:278
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition umachine.h:109
void uregex_getFindProgressCallback(const URegularExpression *regexp, URegexFindProgressCallback **callback, const void **context, UErrorCode *status)
Get the find progress callback function for this URegularExpression.
UBool URegexFindProgressCallback(const void *context, int64_t matchIndex)
Function pointer for a regular expression find callback function.
Definition uregex.h:1550
UBool URegexMatchCallback(const void *context, int32_t steps)
Function pointer for a regular expression matching callback function.
Definition uregex.h:1476
UBool uregex_matches64(URegularExpression *regexp, int64_t startIndex, UErrorCode *status)
64bit version of uregex_matches.
void uregex_useAnchoringBounds(URegularExpression *regexp, UBool b, UErrorCode *status)
Set whether this URegularExpression is using Anchoring Bounds for its region.
UText * uregex_replaceAllUText(URegularExpression *regexp, UText *replacement, UText *dest, UErrorCode *status)
Replaces every substring of the input that matches the pattern with the given replacement string.
void uregex_refreshUText(URegularExpression *regexp, UText *text, UErrorCode *status)
Set the subject text string upon which the regular expression is looking for matches without changing...
int32_t uregex_replaceFirst(URegularExpression *regexp, const UChar *replacementText, int32_t replacementLength, UChar *destBuf, int32_t destCapacity, UErrorCode *status)
Replaces the first substring of the input that matches the pattern with the given replacement string.
const UChar * uregex_getText(URegularExpression *regexp, int32_t *textLength, UErrorCode *status)
Get the subject text that is currently associated with this regular expression object.
URegularExpression * uregex_openC(const char *pattern, uint32_t flags, UParseError *pe, UErrorCode *status)
Open (compile) an ICU regular expression.
void uregex_getMatchCallback(const URegularExpression *regexp, URegexMatchCallback **callback, const void **context, UErrorCode *status)
Get the callback function for this URegularExpression.
int32_t uregex_split(URegularExpression *regexp, UChar *destBuf, int32_t destCapacity, int32_t *requiredCapacity, UChar *destFields[], int32_t destFieldsCapacity, UErrorCode *status)
Split a string into fields.
int32_t uregex_regionEnd(const URegularExpression *regexp, UErrorCode *status)
Reports the end index (exclusive) of the matching region for this URegularExpression.
void uregex_setStackLimit(URegularExpression *regexp, int32_t limit, UErrorCode *status)
Set the amount of heap storage available for use by the match backtracking stack.
void uregex_reset(URegularExpression *regexp, int32_t index, UErrorCode *status)
Reset any saved state from the previous match.
int64_t uregex_end64(URegularExpression *regexp, int32_t groupNum, UErrorCode *status)
64bit version of uregex_end.
UBool uregex_hasTransparentBounds(const URegularExpression *regexp, UErrorCode *status)
Queries the transparency of region bounds for this URegularExpression.
UBool uregex_lookingAt64(URegularExpression *regexp, int64_t startIndex, UErrorCode *status)
64bit version of uregex_lookingAt.
int32_t uregex_end(URegularExpression *regexp, int32_t groupNum, UErrorCode *status)
Returns the index in the input string of the position following the end of the text matched by the sp...
int32_t uregex_getStackLimit(const URegularExpression *regexp, UErrorCode *status)
Get the size of the heap storage available for use by the back tracking stack.
int32_t uregex_appendTail(URegularExpression *regexp, UChar **destBuf, int32_t *destCapacity, UErrorCode *status)
As the final step in a find-and-replace operation, append the remainder of the input string,...
UText * uregex_replaceFirstUText(URegularExpression *regexp, UText *replacement, UText *dest, UErrorCode *status)
Replaces the first substring of the input that matches the pattern with the given replacement string.
int32_t uregex_replaceAll(URegularExpression *regexp, const UChar *replacementText, int32_t replacementLength, UChar *destBuf, int32_t destCapacity, UErrorCode *status)
Replaces every substring of the input that matches the pattern with the given replacement string.
int32_t uregex_appendReplacement(URegularExpression *regexp, const UChar *replacementText, int32_t replacementLength, UChar **destBuf, int32_t *destCapacity, UErrorCode *status)
Implements a replace operation intended to be used as part of an incremental find-and-replace.
UText * uregex_getUText(URegularExpression *regexp, UText *dest, UErrorCode *status)
Get the subject text that is currently associated with this regular expression object.
void uregex_setText(URegularExpression *regexp, const UChar *text, int32_t textLength, UErrorCode *status)
Set the subject text string upon which the regular expression will look for matches.
int32_t uregex_regionStart(const URegularExpression *regexp, UErrorCode *status)
Reports the start index of the matching region.
UBool uregex_lookingAt(URegularExpression *regexp, int32_t startIndex, UErrorCode *status)
Attempts to match the input string, starting from the specified index, against the pattern.
int64_t uregex_start64(URegularExpression *regexp, int32_t groupNum, UErrorCode *status)
64bit version of uregex_start.
struct URegularExpression URegularExpression
Structure representing a compiled regular expression, plus the results of a match operation.
Definition uregex.h:40
int32_t uregex_start(URegularExpression *regexp, int32_t groupNum, UErrorCode *status)
Returns the index in the input string of the start of the text matched by the specified capture group...
void uregex_setRegion64(URegularExpression *regexp, int64_t regionStart, int64_t regionLimit, UErrorCode *status)
64bit version of uregex_setRegion.
UBool uregex_requireEnd(const URegularExpression *regexp, UErrorCode *status)
Return TRUE the most recent match succeeded and additional input could cause it to fail.
UBool uregex_matches(URegularExpression *regexp, int32_t startIndex, UErrorCode *status)
Attempts to match the input string against the pattern.
UBool uregex_find(URegularExpression *regexp, int32_t startIndex, UErrorCode *status)
Find the first matching substring of the input string that matches the pattern.
UText * uregex_patternUText(const URegularExpression *regexp, UErrorCode *status)
Returns the source text of the pattern for this regular expression.
void uregex_setTimeLimit(URegularExpression *regexp, int32_t limit, UErrorCode *status)
Set a processing time limit for match operations with this URegularExpression.
int32_t uregex_splitUText(URegularExpression *regexp, UText *destFields[], int32_t destFieldsCapacity, UErrorCode *status)
Split a string into fields.
void uregex_close(URegularExpression *regexp)
Close the regular expression, recovering all resources (memory) it was holding.
int32_t uregex_getTimeLimit(const URegularExpression *regexp, UErrorCode *status)
Get the time limit for for matches with this URegularExpression.
URegexpFlag
Constants for Regular Expression Match Modes.
Definition uregex.h:47
@ UREGEX_DOTALL
If set, '.
Definition uregex.h:63
@ UREGEX_COMMENTS
Allow white space and comments within patterns.
Definition uregex.h:59
@ UREGEX_MULTILINE
Control behavior of "$" and "^" If set, recognize line terminators within string, otherwise,...
Definition uregex.h:81
@ UREGEX_LITERAL
If set, treat the entire pattern as a literal string.
Definition uregex.h:75
@ UREGEX_CASE_INSENSITIVE
Enable case insensitive matching.
Definition uregex.h:56
@ UREGEX_CANON_EQ
Forces normalization of pattern and strings.
Definition uregex.h:53
@ UREGEX_ERROR_ON_UNKNOWN_ESCAPES
Error on Unrecognized backslash escapes.
Definition uregex.h:106
@ UREGEX_UWORD
Unicode word boundaries.
Definition uregex.h:97
@ UREGEX_UNIX_LINES
Unix-only line endings.
Definition uregex.h:88
UBool uregex_hitEnd(const URegularExpression *regexp, UErrorCode *status)
Return TRUE if the most recent matching operation touched the end of the text being processed.
void uregex_setUText(URegularExpression *regexp, UText *text, UErrorCode *status)
Set the subject text string upon which the regular expression will look for matches.
void uregex_setMatchCallback(URegularExpression *regexp, URegexMatchCallback *callback, const void *context, UErrorCode *status)
Set a callback function for this URegularExpression.
void uregex_setFindProgressCallback(URegularExpression *regexp, URegexFindProgressCallback *callback, const void *context, UErrorCode *status)
Set the find progress callback function for this URegularExpression.
URegularExpression * uregex_clone(const URegularExpression *regexp, UErrorCode *status)
Make a copy of a compiled regular expression.
UBool uregex_findNext(URegularExpression *regexp, UErrorCode *status)
Find the next pattern match in the input string.
void uregex_reset64(URegularExpression *regexp, int64_t index, UErrorCode *status)
64bit version of uregex_reset.
void uregex_setRegion(URegularExpression *regexp, int32_t regionStart, int32_t regionLimit, UErrorCode *status)
Sets the limits of the matching region for this URegularExpression.
UText * uregex_appendTailUText(URegularExpression *regexp, UText *dest, UErrorCode *status)
As the final step in a find-and-replace operation, append the remainder of the input string,...
int32_t uregex_group(URegularExpression *regexp, int32_t groupNum, UChar *dest, int32_t destCapacity, UErrorCode *status)
Extract the string for the specified matching expression or subexpression.
UText * uregex_groupUText(URegularExpression *regexp, int32_t groupNum, UText *dest, int64_t *groupLength, UErrorCode *status)
Returns a shallow immutable clone of the entire input string.
URegularExpression * uregex_open(const UChar *pattern, int32_t patternLength, uint32_t flags, UParseError *pe, UErrorCode *status)
Open (compile) an ICU regular expression.
const UChar * uregex_pattern(const URegularExpression *regexp, int32_t *patLength, UErrorCode *status)
Returns a pointer to the source form of the pattern for this regular expression.
UBool uregex_hasAnchoringBounds(const URegularExpression *regexp, UErrorCode *status)
Return true if this URegularExpression is using anchoring bounds.
UText * uregex_groupUTextDeep(URegularExpression *regexp, int32_t groupNum, UText *dest, UErrorCode *status)
Extract the string for the specified matching expression or subexpression.
void uregex_useTransparentBounds(URegularExpression *regexp, UBool b, UErrorCode *status)
Sets the transparency of region bounds for this URegularExpression.
int64_t uregex_regionStart64(const URegularExpression *regexp, UErrorCode *status)
64bit version of uregex_regionStart.
int32_t uregex_groupCount(URegularExpression *regexp, UErrorCode *status)
Get the number of capturing groups in this regular expression's pattern.
URegularExpression * uregex_openUText(UText *pattern, uint32_t flags, UParseError *pe, UErrorCode *status)
Open (compile) an ICU regular expression.
int64_t uregex_regionEnd64(const URegularExpression *regexp, UErrorCode *status)
64bit version of uregex_regionEnd.
void uregex_appendReplacementUText(URegularExpression *regexp, UText *replacementText, UText *dest, UErrorCode *status)
Implements a replace operation intended to be used as part of an incremental find-and-replace.
int32_t uregex_flags(const URegularExpression *regexp, UErrorCode *status)
Get the match mode flags that were specified when compiling this regular expression.
UBool uregex_find64(URegularExpression *regexp, int64_t startIndex, UErrorCode *status)
64bit version of uregex_find.
void uregex_setRegionAndStart(URegularExpression *regexp, int64_t regionStart, int64_t regionLimit, int64_t startIndex, UErrorCode *status)
Set the matching region and the starting index for subsequent matches in a single operation.
C API: Abstract Unicode Text API.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129