Home Units Hierarchy Routines All identifiers

Unit unaRE

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

RE [ IEEE Std 1003.1 ] http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html

Version 2.5.2011.12 First release

Version 2.5.2012.01 - some fixes of * handling

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class unaRegExp RegExp utility class.

Functions and Procedures

function parse(const regexp: wString; var ea: pointer): int; overload;
procedure disposeEA(var ea: pointer);
function rematch(const subject, regexp: wString; out matchlen: int; startFrom: int = 1): int; overload;
function rematch(startFrom: int; const subject, regexp: wString): string; overload;
function rematch(ea: pointer; const subject: wString; out matchlen: int; startFrom: int = 1): int; overload;
function replace(const subject, regexp, substitution: wString; startFrom: int = 1; global: bool = false): wString; overload;
function replace(ea: pointer; const subject, substitution: wString; startFrom: int = 1; global: bool = false): wString; overload;

Constants

RE_DUP_MAX = maxInt;
unaRE_error_backref = -13;
unaRE_error_emptySeq = -15;
unaRE_error_escape = -12;
unaRE_error_escape2 = -14;
unaRE_error_mm = -10;
unaRE_error_mmOrder = -11;
unaRE_error_noMatch = -1;
unaRE_error_OK = 0;
unaRE_error_sroot = -4;
unaRE_error_srootExp = -5;

Description

Functions and Procedures

function parse(const regexp: wString; var ea: pointer): int; overload;

Parses regexp. Don't forget to dispose the result with disposeEA()

Parameters
startFrom
start lookup from this position
Returns

unaRE_error_OK, or one of unaRE_error_XXX error codes

procedure disposeEA(var ea: pointer);

Releases memory taken by parsed expression

function rematch(const subject, regexp: wString; out matchlen: int; startFrom: int = 1): int; overload;

Looks for first match from specified position.

Parameters
subject
text to find the match in
regexp
regular expression
startFrom
start lookup from this position (from 1 to length(subject) )
Returns

position of new match, or one of unaRE_error_XXX error codes

function rematch(startFrom: int; const subject, regexp: wString): string; overload;

Looks for first match from specified position.

Parameters
subject
text to find the match in
regexp
regular expression
startFrom
start lookup from this position (from 1 to length(subject) )
Returns

first match, or empty string

function rematch(ea: pointer; const subject: wString; out matchlen: int; startFrom: int = 1): int; overload;

Looks for first match from specified position.

Parameters
ea
parsed regexp (use parse() to receive it)
subject
text to find the match in
startFrom
start lookup from this position (from 1 to length(subject) )
Returns

position of new match, or one of unaRE_error_XXX error codes

function replace(const subject, regexp, substitution: wString; startFrom: int = 1; global: bool = false): wString; overload;

Replaces first or all matches with substitution, which can include backrefs.

Parameters
subject
text to find the match and replace in
regexp
regular expression
substitution
replace any matches with that (may include backrefs)
startFrom
start lookup from this position (from 1 to length(subject) )
global
repeat replacement for whole string
Returns

resulting string

function replace(ea: pointer; const subject, substitution: wString; startFrom: int = 1; global: bool = false): wString; overload;

Replaces first or all matches with substitution, which can include backrefs.

Parameters
ea
parsed regular expression (use parse() to receive it from regexp string)
subject
text to find the match and replace in
substitution
replace any matches with that (may include backrefs)
startFrom
start lookup from this position (from 1 to length(subject) )
global
repeat replacement for whole string
Returns

resulting string

Constants

RE_DUP_MAX = maxInt;
 
unaRE_error_backref = -13;

unknown escape

unaRE_error_emptySeq = -15;

out of escape chars

unaRE_error_escape = -12;

min/max out of order in {}

unaRE_error_escape2 = -14;

wrong backref

unaRE_error_mm = -10;

root must be a subexpression (should not happen, consider as internal error)

unaRE_error_mmOrder = -11;

general error in {}

unaRE_error_noMatch = -1;

no error

unaRE_error_OK = 0;

max count of elements for * exp

unaRE_error_sroot = -4;

no match found

unaRE_error_srootExp = -5;

rare error in sroot (should not happen, consider as internal error)

Author

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09