ICU 4.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
uregex.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 2004-2009, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * file name: regex.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 
23 #ifndef UREGEX_H
24 #define UREGEX_H
25 
26 #include "unicode/utypes.h"
27 
28 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
29 
30 #include "unicode/parseerr.h"
31 
32 struct URegularExpression;
39 
40 
45 typedef enum URegexpFlag{
46 
47 #ifndef U_HIDE_DRAFT_API
48 
52 #endif
53 
55 
58 
62 
75 
81 
88 
96  UREGEX_UWORD = 256,
97 
106 
107 } URegexpFlag;
108 
131 uregex_open( const UChar *pattern,
132  int32_t patternLength,
133  uint32_t flags,
134  UParseError *pe,
135  UErrorCode *status);
136 
160 #if !UCONFIG_NO_CONVERSION
162 uregex_openC( const char *pattern,
163  uint32_t flags,
164  UParseError *pe,
165  UErrorCode *status);
166 #endif
167 
168 
169 
177 U_STABLE void U_EXPORT2
179 
199 uregex_clone(const URegularExpression *regexp, UErrorCode *status);
200 
217 U_STABLE const UChar * U_EXPORT2
218 uregex_pattern(const URegularExpression *regexp,
219  int32_t *patLength,
220  UErrorCode *status);
221 
222 
232 uregex_flags(const URegularExpression *regexp,
233  UErrorCode *status);
234 
235 
256 U_STABLE void U_EXPORT2
258  const UChar *text,
259  int32_t textLength,
260  UErrorCode *status);
261 
278 U_STABLE const UChar * U_EXPORT2
280  int32_t *textLength,
281  UErrorCode *status);
282 
305  int32_t startIndex,
306  UErrorCode *status);
307 
333  int32_t startIndex,
334  UErrorCode *status);
335 
357  int32_t startIndex,
358  UErrorCode *status);
359 
375  UErrorCode *status);
376 
386  UErrorCode *status);
387 
406  int32_t groupNum,
407  UChar *dest,
408  int32_t destCapacity,
409  UErrorCode *status);
410 
411 
428  int32_t groupNum,
429  UErrorCode *status);
430 
446  int32_t groupNum,
447  UErrorCode *status);
448 
462 U_STABLE void U_EXPORT2
464  int32_t index,
465  UErrorCode *status);
466 
467 
487 U_DRAFT void U_EXPORT2
489  int32_t regionStart,
490  int32_t regionLimit,
491  UErrorCode *status);
492 
504  UErrorCode *status);
505 
506 
507 
520  UErrorCode *status);
521 
534  UErrorCode *status);
535 
536 
556 U_DRAFT void U_EXPORT2
558  UBool b,
559  UErrorCode *status);
560 
561 
573  UErrorCode *status);
574 
575 
589 U_DRAFT void U_EXPORT2
591  UBool b,
592  UErrorCode *status);
593 
605 uregex_hitEnd(const URegularExpression *regexp,
606  UErrorCode *status);
607 
621  UErrorCode *status);
622 
623 
624 
625 
626 
653  const UChar *replacementText,
654  int32_t replacementLength,
655  UChar *destBuf,
656  int32_t destCapacity,
657  UErrorCode *status);
658 
659 
686  const UChar *replacementText,
687  int32_t replacementLength,
688  UChar *destBuf,
689  int32_t destCapacity,
690  UErrorCode *status);
691 
692 
741  const UChar *replacementText,
742  int32_t replacementLength,
743  UChar **destBuf,
744  int32_t *destCapacity,
745  UErrorCode *status);
746 
747 
774  UChar **destBuf,
775  int32_t *destCapacity,
776  UErrorCode *status);
777 
778 
779 
780 
837  UChar *destBuf,
838  int32_t destCapacity,
839  int32_t *requiredCapacity,
840  UChar *destFields[],
841  int32_t destFieldsCapacity,
842  UErrorCode *status);
843 
844 
845 
846 
869 U_DRAFT void U_EXPORT2
871  int32_t limit,
872  UErrorCode *status);
873 
885  UErrorCode *status);
886 
907 U_DRAFT void U_EXPORT2
909  int32_t limit,
910  UErrorCode *status);
911 
921  UErrorCode *status);
922 
923 
944  const void *context,
945  int32_t steps);
947 
962 U_DRAFT void U_EXPORT2
964  URegexMatchCallback *callback,
965  const void *context,
966  UErrorCode *status);
967 
968 
980 U_DRAFT void U_EXPORT2
982  URegexMatchCallback **callback,
983  const void **context,
984  UErrorCode *status);
985 
986 
987 
988 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */
989 #endif /* UREGEX_H */
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.
URegularExpression * uregex_openC(const char *pattern, uint32_t flags, UParseError *pe, UErrorCode *status)
Open (compile) an ICU regular expression.
Forces normalization of pattern and strings.
Definition: uregex.h:51
int32_t uregex_getTimeLimit(const URegularExpression *regexp, UErrorCode *status)
Get the time limit for for matches with this URegularExpression.
int32_t uregex_groupCount(URegularExpression *regexp, UErrorCode *status)
Get the number of capturing groups in this regular expression's pattern.
Control behavior of "$" and "^" If set, recognize line terminators within string, otherwise...
Definition: uregex.h:80
void uregex_reset(URegularExpression *regexp, int32_t index, UErrorCode *status)
Reset any saved state from the previous match.
UBool uregex_find(URegularExpression *regexp, int32_t startIndex, UErrorCode *status)
Find the first matching substring of the input string that matches the pattern.
void uregex_getMatchCallback(const URegularExpression *regexp, URegexMatchCallback **callback, const void **context, UErrorCode *status)
Get the callback function for this URegularExpression.
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...
int32_t uregex_regionEnd(const URegularExpression *regexp, UErrorCode *status)
Reports the end index (exclusive) of the matching region for this URegularExpression.
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: utypes.h:254
If set, '.
Definition: uregex.h:61
Unix-only line endings.
Definition: uregex.h:87
UBool uregex_requireEnd(const URegularExpression *regexp, UErrorCode *status)
Return TRUE the most recent match succeeded and additional input could cause it to fail...
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...
void uregex_setRegion(URegularExpression *regexp, int32_t regionStart, int32_t regionLimit, UErrorCode *status)
Sets the limits of the matching region 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_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...
UBool uregex_matches(URegularExpression *regexp, int32_t startIndex, UErrorCode *status)
Attempts to match the input string against the pattern.
URegularExpression * uregex_open(const UChar *pattern, int32_t patternLength, uint32_t flags, UParseError *pe, UErrorCode *status)
Open (compile) an ICU regular expression.
unsigned int uint32_t
Define 64 bit limits.
Definition: pwin32.h:147
void uregex_close(URegularExpression *regexp)
Close the regular expression, recovering all resources (memory) it was holding.
UBool uregex_findNext(URegularExpression *regexp, UErrorCode *status)
Find the next pattern match in the input string.
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:101
int32_t uregex_getStackLimit(const URegularExpression *regexp, UErrorCode *status)
Get the size of the heap storage available for use by the back tracking stack.
URegularExpression * uregex_clone(const URegularExpression *regexp, UErrorCode *status)
Make a copy of a compiled regular expression.
URegexpFlag
Constants for Regular Expression Match Modes.
Definition: uregex.h:45
void uregex_setStackLimit(URegularExpression *regexp, int32_t limit, UErrorCode *status)
Set the amount of heap storage avaliable for use by the match backtracking stack. ...
Allow white space and comments within patterns.
Definition: uregex.h:57
void uregex_useAnchoringBounds(URegularExpression *regexp, UBool b, UErrorCode *status)
Set whether this URegularExpression is using Anchoring Bounds for its region.
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.
UBool uregex_hasTransparentBounds(const URegularExpression *regexp, UErrorCode *status)
Queries the transparency of region bounds for this URegularExpression.
const UChar * uregex_pattern(const URegularExpression *regexp, int32_t *patLength, UErrorCode *status)
Return a pointer to the source form of the pattern for this regular expression.
void uregex_setMatchCallback(URegularExpression *regexp, URegexMatchCallback *callback, const void *context, UErrorCode *status)
Set a callback function for this URegularExpression.
#define U_EXPORT2
Definition: platform.h:338
int32_t uregex_flags(const URegularExpression *regexp, UErrorCode *status)
Get the match mode flags that were specified when compiling this regular expression.
struct URegularExpression URegularExpression
Structure representing a compiled regular rexpression, plus the results of a match operation...
Definition: uregex.h:38
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:299
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:102
UBool URegexMatchCallback(const void *context, int32_t steps)
Function pointer for a regular expression matching callback function.
Definition: uregex.h:943
UBool uregex_hasAnchoringBounds(const URegularExpression *regexp, UErrorCode *status)
Return true if this URegularExpression is using anchoring bounds.
int32_t uregex_regionStart(const URegularExpression *regexp, UErrorCode *status)
Reports the start index of the matching region.
C API: Parse Error Information.
Unicode word boundaries.
Definition: uregex.h:96
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.
Error on Unrecognized backslash escapes.
Definition: uregex.h:105
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
If set, treat the entire pattern as a literal string.
Definition: uregex.h:74
void uregex_useTransparentBounds(URegularExpression *regexp, UBool b, UErrorCode *status)
Sets the transparency of region bounds for this URegularExpression.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:56
Basic definitions for ICU, for both C and C++ APIs.
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...
Enable case insensitive matching.
Definition: uregex.h:54
const UChar * uregex_getText(URegularExpression *regexp, int32_t *textLength, UErrorCode *status)
Get the subject text that is currently associated with this regular expression object.
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_setTimeLimit(URegularExpression *regexp, int32_t limit, UErrorCode *status)
Set a processing time limit for match operations with this URegularExpression.
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition: umachine.h:119
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...
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:117
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208
UBool uregex_lookingAt(URegularExpression *regexp, int32_t startIndex, UErrorCode *status)
Attempts to match the input string, starting from the specified index, against the pattern...