Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 10.0   10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2   11.3    Statistic    FMM    Blog  

RegEx.Extract

Extracts found text.

Component Version macOS Windows Linux Server iOS SDK
RegEx 11.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "RegEx.Extract"; Text; Pattern; Rewrite { ; Options } )   More

Parameters

Parameter Description Example Flags
Text The text to use. "hello world"
Pattern The pattern to use. "l+"
Rewrite The output pattern. "\1\1"
Options The PCRE options.
Can be given as text or number.
0 Optional

Result

Returns OK or error.

Description

Extracts found text.
Similar like RegEx.Replace, but returns only the found text given to the pattern for output.

Examples

Extract phone number:

MBS( "RegEx.Extract"; "Call us at 01234/5678-90 to speak to sales."; "([0-9][0-9/\\-]+[0-9])"; "\1"; 1 )

Example result: 01234/5678-90

Find a german IBAN in a text:

Let([
Input = "Hello DE29100100100987654321 World!";
R = MBS( "IBAN.RegEx"; "DE");
R = substitute(R; "^"; "");
R = substitute(R; "$"; "");

Found = MBS("RegEx.Extract"; input; R; "\\0"; 0 )
]; Found)

Example result: DE29100100100987654321

Look for invoice number via regex:

MBS("RegEx.Extract";
"Rechnung Nr. 1234567 vom Mai 2020";
"(Nr|Number|No|Nummer|Nombre|Numbre)([. :]*)(\d+)";
"\3";
"caseless¶greedy")

Extract MBS Plugin version from container with Windows:

# extract plugin file
Set Variable [ $InfoText ; Value: MBS( "Container.GetText"; Install Plugin Update if needed::Plugin File Win 64bit; "FILE"; "Windows") ] 
# get version as text
Set Variable [ $version ; Value: MBS( "RegEx.Extract"; $infoText; "MBS FileMaker Plugin (\d+.\d+.\d+.\d+)"; "\1"; "greedy, caseless" ) ] 
Show Custom Dialog [ "MBS Version" ; $version ]

Extract MBS Plugin version from container with Linux:

# extract plugin file
Set Variable [ $InfoText ; Value: MBS( "Container.GetText"; Install Plugin Update if needed::Plugin File Linux; "FILE") ] 
# get version as text
Set Variable [ $version ; Value: MBS( "RegEx.Extract"; $infoText; "MBS FileMaker Plugin, version (\d+.\d+.\d+.\d+),"; "\1"; "greedy, caseless" ) ] 
Show Custom Dialog [ "MBS Version" ; $version ]

Extract MBS Plugin version from container with macOS:

# extract info file with metadata
Set Variable [ $InfoFile ; Value: MBS( "Archive.ExtractFile"; Install Plugin Update if needed::Plugin File Mac; "MBS.fmplugin/Contents/Info.plist" ) ] 
# get version as text
Set Variable [ $version ; Value: MBS( "RegEx.Extract"; $infoText; "<key>CFBundleVersion</key>\s*<string>(.*)</string>"; "\1"; "greedy, caseless" ) ] 
Show Custom Dialog [ "MBS Version" ; $version ]

See also

Release notes

Example Databases

Blog Entries

Created 19th February 2021, last changed 19th April 2021


RegEx.Execute - RegEx.FindMatches

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins

Start Chat