Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

URegex Class Reference

Inheritance diagram for URegex:

Groups List of all members.

Public Types

enum  Flag {
  None = 0, CaseInsensitive = 2, Comments = 4, MultiLine = 8,
  DotAll = 32, CanonEq = 128, UWord = 256
}

Public Member Functions

 this (wchar[] pattern, Flag flags=Flag.None, ParseError *pe=null)
 this (UText pattern, Flag flags=Flag.None, ParseError *pe=null)
 ~this ()
URegex clone ()
UString getPattern ()
Flag getFlags ()
void setText (UText t)
UText getText ()
Groups groups ()
void group (UString s, uint index)
uint groupCount ()
uint start (uint index=0)
uint end (uint index=0)
void reset (uint startIndex)
bool match (uint startIndex)
bool probe (uint startIndex)
bool next (uint startIndex=uint.max)
uint replaceAll (UText replace, UString result)
uint replaceFirst (UText replace, UString result)
uint split (wchar[][] fields)

Static Public Member Functions

static this ()
static ~this ()

Static Public Attributes

static FunctionLoader Bind[] targets

Private Member Functions

 this (Handle handle)

Private Attributes

Handle handle
UText theText
wchar[] g0
wchar[] g1
wchar[] g2
wchar[] g3
wchar[] g4
wchar[] g5
wchar[] g6
wchar[] g7
wchar[] g8
wchar[] g9

Static Private Attributes

static void * library

Detailed Description

Apis for an engine that provides regular-expression searching of UTF16 strings.

See http://icu.sourceforge.net/apiref/icu4c/uregex_8h.html for full details.

Definition at line 125 of file URegex.d.


Member Enumeration Documentation

enum Flag
 

Enumeration values:
None 
CaseInsensitive 
Comments 
MultiLine 
DotAll 
CanonEq 
UWord 

Definition at line 131 of file URegex.d.


Constructor & Destructor Documentation

~this  )  [inline]
 

Close the regular expression, recovering all resources (memory) it was holding

Definition at line 213 of file URegex.d.

References handle.

static ~this  )  [inline, static]
 

Definition at line 696 of file URegex.d.

References library.


Member Function Documentation

this wchar[]  pattern,
Flag  flags = Flag.None,
ParseError *  pe = null
[inline]
 

Compiles the regular expression in string form into an internal representation using the specified match mode flags. The resulting regular expression handle can then be used to perform various matching operations.

Definition at line 169 of file URegex.d.

References handle, and ICU::testError().

this UText  pattern,
Flag  flags = Flag.None,
ParseError *  pe = null
[inline]
 

Compiles the regular expression in string form into an internal representation using the specified match mode flags. The resulting regular expression handle can then be used to perform various matching operations.

Definition at line 187 of file URegex.d.

this Handle  handle  )  [inline, private]
 

Internal constructor; used for cloning

Definition at line 198 of file URegex.d.

References handle.

URegex clone  )  [inline]
 

Cloning a regular expression is faster than opening a second instance from the source form of the expression, and requires less memory.

Note that the current input string and the position of any matched text within it are not cloned; only the pattern itself and and the match mode flags are copied.

Cloning can be particularly useful to threaded applications that perform multiple match operations in parallel. Each concurrent RE operation requires its own instance of a URegularExpression.

Definition at line 235 of file URegex.d.

References handle, ICU::testError(), and URegex.

UString getPattern  )  [inline]
 

Return a copy of the source form of the pattern for this regular expression

Definition at line 251 of file URegex.d.

References handle, ICU::testError(), UString, and x.

Flag getFlags  )  [inline]
 

Get the match mode flags that were specified when compiling this regular expression

Definition at line 268 of file URegex.d.

References handle, and ICU::testError().

void setText UText  t  )  [inline]
 

Set the subject text string upon which the regular expression will look for matches.

This function may be called any number of times, allowing the regular expression pattern to be applied to different strings.

Regular expression matching operations work directly on the application's string data. No copy is made. The subject string data must not be altered after calling this function until after all regular expression operations involving this string data are completed.

Zero length strings are permitted. In this case, no subsequent match operation will dereference the text string pointer.

Definition at line 296 of file URegex.d.

References UText::get(), handle, UText::length(), ICU::testError(), and theText.

UText getText  )  [inline]
 

Get the subject text that is currently associated with this regular expression object. This simply returns whatever was previously supplied via setText().

Note that this returns a read-only reference to the text.

Definition at line 315 of file URegex.d.

References theText.

Groups groups  )  [inline]
 

Return a set of slices representing the parenthesised groups. This can be used in the following manner:

                wchar msg;

                if (regex.next())
                    with (regex.groups())
                          msg ~= g1 ~ ":" ~ g2

Note that g0 represents the entire match, whereas g1 through g9 represent the parenthesised expressions.

Definition at line 338 of file URegex.d.

References end(), UText::get(), groupCount(), start(), and theText.

void group UString  s,
uint  index
[inline]
 

Extract the string for the specified matching expression or subexpression. UString 's' is the destination for the match.

Group #0 is the complete string of matched text. Group #1 is the text matched by the first set of capturing parentheses.

Definition at line 361 of file URegex.d.

References UString::format(), and handle.

uint groupCount  )  [inline]
 

Get the number of capturing groups in this regular expression's pattern

Definition at line 378 of file URegex.d.

References handle, and ICU::testError().

Referenced by groups().

uint start uint  index = 0  )  [inline]
 

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 the capture group was not part of the last match. Group #0 refers to the complete range of matched text. Group #1 refers to the text matched by the first set of capturing parentheses

Definition at line 400 of file URegex.d.

References handle, and ICU::testError().

Referenced by groups(), and split().

uint end uint  index = 0  )  [inline]
 

Returns the index in the input string of the position following the end of the text matched by the specified capture group.

Return -1 if the capture group was not part of the last match. Group #0 refers to the complete range of matched text. Group #1 refers to the text matched by the first set of capturing parentheses.

Definition at line 422 of file URegex.d.

References handle, and ICU::testError().

Referenced by groups(), and split().

void reset uint  startIndex  )  [inline]
 

Reset any saved state from the previous match.

Has the effect of causing uregex_findNext to begin at the specified index, and causing uregex_start(), uregex_end() and uregex_group() to return an error indicating that there is no match information available.

Definition at line 442 of file URegex.d.

References handle, and ICU::testError().

bool match uint  startIndex  )  [inline]
 

Attempts to match the input string, beginning at startIndex, against the pattern.

To succeed, the match must extend to the end of the input string

Definition at line 460 of file URegex.d.

References handle, and ICU::testError().

bool probe uint  startIndex  )  [inline]
 

Attempts to match the input string, starting from the specified index, against the pattern.

The match may be of any length, and is not required to extend to the end of the input string. Contrast with match()

Definition at line 479 of file URegex.d.

References handle, and ICU::testError().

bool next uint  startIndex = uint.max  )  [inline]
 

Returns whether the text matches the search pattern, starting from the current position.

If startIndex is specified, the current position is moved to the specified location before the seach is initiated.

Definition at line 498 of file URegex.d.

References handle, and ICU::testError().

uint replaceAll UText  replace,
UString  result
[inline]
 

Replaces every substring of the input that matches the pattern with the given replacement string.

This is a convenience function that provides a complete find-and-replace-all operation.

This method scans the input string looking for matches of the pattern. Input that is not part of any match is copied unchanged to the destination buffer. Matched regions are replaced in the output buffer by the replacement string. The replacement string may contain references to capture groups; these take the form of $1, $2, etc.

The provided 'result' will contain the results, and should be set with a length sufficient to house the entire result. Upon completion, the 'result' is shortened appropriately and the total extent (length) of the operation is returned. Set the initital length of 'result' using the UString method truncate().

The returned extent should be checked to ensure it is not longer than the length of 'result'. If it is longer, then the result has been truncated.

Definition at line 538 of file URegex.d.

References UText::get(), handle, UText::length(), ICU::testError(), and UString::truncate().

uint replaceFirst UText  replace,
UString  result
[inline]
 

Replaces the first substring of the input that matches the pattern with the given replacement string.

This is a convenience function that provides a complete find-and-replace operation.

This method scans the input string looking for a match of the pattern. All input that is not part of the match is copied unchanged to the destination buffer. The matched region is replaced in the output buffer by the replacement string. The replacement string may contain references to capture groups; these take the form of $1, $2, etc

The provided 'result' will contain the results, and should be set with a length sufficient to house the entire result. Upon completion, the 'result' is shortened appropriately and the total extent (length) of the operation is returned. Set the initital length of 'result' using the UString method truncate().

The returned extent should be checked to ensure it is not longer than the length of 'result'. If it is longer, then the result has been truncated.

Definition at line 576 of file URegex.d.

References UText::get(), handle, UText::length(), ICU::testError(), and UString::truncate().

uint split wchar  fields[][]  )  [inline]
 

Split the text up into slices (fields), where each slice represents the text situated between each pattern matched within the text. The pattern is expected to represent one or more slice delimiters.

Definition at line 595 of file URegex.d.

References end(), UText::get(), handle, start(), ICU::testError(), and theText.

static this  )  [inline, static]
 

Definition at line 687 of file URegex.d.

References library, and targets.


Member Data Documentation

Handle handle [private]
 

Definition at line 127 of file URegex.d.

Referenced by clone(), end(), getFlags(), getPattern(), group(), groupCount(), match(), next(), probe(), replaceAll(), replaceFirst(), reset(), setText(), split(), start(), this(), and ~this().

UText theText [private]
 

Definition at line 128 of file URegex.d.

Referenced by getText(), groups(), setText(), and split().

void* library [static, private]
 

Bind the ICU functions from a shared library. This is complicated by the issues regarding D and DLLs on the Windows platform

Definition at line 629 of file URegex.d.

Referenced by this(), and ~this().

FunctionLoader Bind [] targets [static]
 

Initial value:

 
                [
                {cast(void**) &uregex_open,             "uregex_open"}

Definition at line 661 of file URegex.d.

Referenced by this().

wchar [] g0 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g1 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g2 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g3 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g4 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g5 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g6 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g7 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g8 [inherited]
 

Definition at line 103 of file URegex.d.

wchar [] g9 [inherited]
 

Definition at line 103 of file URegex.d.


The documentation for this class was generated from the following file:
Generated on Mon Nov 14 11:00:05 2005 for Mango by  doxygen 1.4.0