Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

RegEx.Results

Queries the result from execute.

Component Version macOS Windows Linux Server iOS SDK
RegEx 4.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "RegEx.Results"; RegExRef )   More

Parameters

Parameter Description Example
RegExRef The reference number for the regular expression returned from RegEx.Compile. $regex

Result

Returns text or error.

Description

Queries the result from execute.
The result are offsets into the text to search. Two for the whole match followed by 2 for each sub pattern.

Examples

Loop and find all matches for pattern:

Set Variable [ $pattern ; Value: "(USt\-?ID:?|USt\-?IdNR\.?:?|Umsatzsteuer\-?ID:?|VAT\-?ID:?)[\s]?(DE)[\s]?([0-9]{9})" ]
Set Variable [ $ExecuteOptions ; Value: 0 ]
Set Variable [ $CompileOptions ; Value: "caseless" ]
Set Variable [ $regex ; Value: MBS("RegEx.Compile"; $Pattern; $CompileOptions) ]
Set Variable [ $offset ; Value: 0 ]

Loop
    Set Variable [ $r ; Value: MBS("RegEx.Execute"; $regex; RegEx::Text; $ExecuteOptions; $offset) ]
    Exit Loop If [ $r < 4 ]
    Set Variable [ $s1 ; Value: MBS("RegEx.Substring"; $RegEx; 1) ]
    Set Variable [ $s2 ; Value: MBS("RegEx.Substring"; $RegEx; 2) ]
    Set Variable [ $s3 ; Value: MBS("RegEx.Substring"; $RegEx; 3) ]
    Show Custom Dialog [ $s1 & ¶ & $s2 & ¶ & $s3 ]
    Exit Loop If [ MBS("IsError") ]
    Set Variable [ $offset ; $offset + Value: GetAsNumber(GetValue(MBS("RegEx.Results"; $regex); 2)) ]
End Loop
Set Variable [ $r ; Value: MBS("RegEx.Release"; $RegEx) ]

See also

This function checks for a license.

Created 26th October 2014, last changed 26th April 2023


RegEx.ReplaceAll - RegEx.Size