Table of Contents

Interface IStdRegExpClass

Namespace
RDCore.SDK.Runtime.Abstract.StdLib
Assembly
RDCore.SDK.dll

RD-VBAL §6.2 VBScript Regular Expressions: the RegExp class of Microsoft VBScript Regular Expressions 5.5, a regular expression and the options it is matched with.

[StdLibClass(null, ProgId = "VBScript.RegExp")]
public interface IStdRegExpClass

Remarks

MS-VBAL has no section for the library. RD-VBA implements it itself, as a class of the standard library: New RegExp needs no reference, and CreateObject("VBScript.RegExp") creates one on any platform, before the machine's servers are asked (ProgId).

A pattern is the syntax of VBScript 5.5 (JScript's, which ECMAScript 3 describes), as MS-VBA matches it: \d, \w, \s and \b are ASCII; . is any character but a line feed; a pattern is checked when it is first matched, not when it is assigned, and a pattern that is not one is a run-time error of its own (5017 to 5021). RD-VBAL §6.2 says what each construct is.

Methods

Execute(VBStringValue)

Matches the pattern against a text: the first match, or every match when Global() is set.

[StdLibMember(null, ReturnType = typeof(IStdMatchCollectionClass))]
RuntimeSemanticsEvaluationResult<VBObjectValue> Execute(VBStringValue sourceString)

Parameters

sourceString VBStringValue

The text.

Returns

RuntimeSemanticsEvaluationResult<VBObjectValue>

A RuntimeSemanticsEvaluationResult whose value is a MatchCollection (IStdMatchCollectionClass), empty when nothing matches.

Remarks

The matches are found when this is called: a change of the pattern or of the options afterwards is not theirs. An empty match is a match, at a position of its own (x* matches "axb" four times).

Global()

Gets whether every match of the pattern is found and replaced (True), or only the first (False, for a new object).

[StdLibMember(null, Kind = StdLibMemberKind.PropertyGet)]
RuntimeSemanticsEvaluationResult<VBBooleanValue> Global()

Returns

RuntimeSemanticsEvaluationResult<VBBooleanValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Global(VBBooleanValue)

Sets whether every match of the pattern is found and replaced, or only the first.

[StdLibMember(null, Kind = StdLibMemberKind.PropertyLet)]
RuntimeSemanticsEvaluationResult Global(VBBooleanValue value)

Parameters

value VBBooleanValue

Whether every match is.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

IgnoreCase()

Gets whether a letter matches either of its cases (True), or only the one it is written in (False, for a new object).

[StdLibMember(null, Kind = StdLibMemberKind.PropertyGet)]
RuntimeSemanticsEvaluationResult<VBBooleanValue> IgnoreCase()

Returns

RuntimeSemanticsEvaluationResult<VBBooleanValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

IgnoreCase(VBBooleanValue)

Sets whether a letter matches either of its cases.

[StdLibMember(null, Kind = StdLibMemberKind.PropertyLet)]
RuntimeSemanticsEvaluationResult IgnoreCase(VBBooleanValue value)

Parameters

value VBBooleanValue

Whether it does.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Multiline()

Gets whether ^ and $ match at the start and the end of each line (True), or only of the whole text (False, for a new object). A line ends at a carriage return or a line feed, each of them: a vbCrLf has an empty line between its two characters.

[StdLibMember(null, Kind = StdLibMemberKind.PropertyGet)]
RuntimeSemanticsEvaluationResult<VBBooleanValue> Multiline()

Returns

RuntimeSemanticsEvaluationResult<VBBooleanValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Multiline(VBBooleanValue)

Sets whether ^ and $ match at the start and the end of each line, or only of the whole text.

[StdLibMember(null, Kind = StdLibMemberKind.PropertyLet)]
RuntimeSemanticsEvaluationResult Multiline(VBBooleanValue value)

Parameters

value VBBooleanValue

Whether they match at each line.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Pattern()

Gets the regular expression: empty for a new object, which matches anywhere.

[StdLibMember(null, Kind = StdLibMemberKind.PropertyGet)]
RuntimeSemanticsEvaluationResult<VBStringValue> Pattern()

Returns

RuntimeSemanticsEvaluationResult<VBStringValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Pattern(VBStringValue)

Sets the regular expression. Any text is one: what is wrong with it is reported when it is matched.

[StdLibMember(null, Kind = StdLibMemberKind.PropertyLet)]
RuntimeSemanticsEvaluationResult Pattern(VBStringValue value)

Parameters

value VBStringValue

The regular expression.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Replace(VBStringValue, VBVariantValue)

Replaces the first match of the pattern in a text, or every match when Global() is set.

RuntimeSemanticsEvaluationResult<VBStringValue> Replace(VBStringValue sourceString, VBVariantValue replaceVar)

Parameters

sourceString VBStringValue

The text.

replaceVar VBVariantValue

What a match is replaced with: text, or a value written as text - a Boolean as -1 or 0, Empty as nothing.
💥TypeMismatch for Null.

Returns

RuntimeSemanticsEvaluationResult<VBStringValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

In the replacement, $1 to $99 are the text of a group ($10 is group 10 when the pattern has ten groups, and $1 followed by 0 otherwise), \(&</code> the match, <code>\)` and \('</code> the text before and after it, and <code>$\) a dollar sign. Anything else - a group the pattern does not have, a $ that starts nothing - is written as it is.

Test(VBStringValue)

Whether the pattern matches anywhere in a text.

RuntimeSemanticsEvaluationResult<VBBooleanValue> Test(VBStringValue sourceString)

Parameters

sourceString VBStringValue

The text.

Returns

RuntimeSemanticsEvaluationResult<VBBooleanValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.