Home Units Hierarchy Routines All identifiers

Class unaRegExp

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type unaRegExp = class(unaObject)

Description

RegExp utility class.

Hierarchy

Overview

Methods

Public constructor create(const regexp: wString);
Public destructor Destroy(); override;
Public function match(out len: int; const subject: wString = ''; startFrom: int = -1): int; overload;
Public function match(const subject: wString = ''; startFrom: int = -1): wString; overload;
Public function replace(const substitution: wString; const subject: wString = ''; startFrom: int = -1; global: bool = false): string;

Properties

Public property error: int read f_error;
Public property lookupPos: int read f_lookupPos write f_lookupPos;
Public property regexp: wString read f_regexp write setRegexp;
Public property subj: wString read f_subj write setSubj;

Description

Methods

Public constructor create(const regexp: wString);

Creates a new class for regexp.

Public destructor Destroy(); override;

Releases regexp resources.

Public function match(out len: int; const subject: wString = ''; startFrom: int = -1): int; overload;

Returns first match position and length. Updates lookupPos property if match was found, new non-empty subject was specified or startFrom was specified. Also updates subj property if new non-empty subject was specified.

Parameters
len
[OUT] match length
subject
source to find match in. If not specified ('') will use subj property instead
startFrom
start lookup from this position. If not specified (-1), value of lookupPos property will be used instead
Returns

first match position, 0 if no match was found or one of unaRE_error_XXX if regexp is incorrect

Public function match(const subject: wString = ''; startFrom: int = -1): wString; overload;

Returns first match. Updates lookupPos property if new non-empty subject was specified or match was found. Also updates subj property if new non-empty subject was specified.

Parameters
subject
source to find match in. If not specified ('') will use subj property instead
startFrom
start lookup from this position. If not specified (-1), value of lookupPos property will be used instead
Returns

first match or empty string if no match found

Public function replace(const substitution: wString; const subject: wString = ''; startFrom: int = -1; global: bool = false): string;

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

Parameters
substitution
replace any matches with that string (may include backrefs)
subject
text to find the match and replace in. If not specified ('') will use subj property instead
startFrom
start lookup from this position. If not specified (-1), value of lookupPos property will be used instead
global
repeat replacement for the whole subject
Returns

resulting string

Properties

Public property error: int read f_error;

Regexp error code, unaRE_error_OK means no error

Public property lookupPos: int read f_lookupPos write f_lookupPos;

Starting position for a lookup.

Public property regexp: wString read f_regexp write setRegexp;

Regexp to use.

Public property subj: wString read f_subj write setSubj;

Subject to use.

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09