Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
RegEx.FindMatches
Finds in a text all matches of a given pattern and returns list.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
RegEx | 5.1 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
RegExRef | The reference number for the regular expression returned from RegEx.Compile. | $regex | |
Text | The text to search. | "Hello" | |
ExecuteOptions | The options for executing. Can be given as text or number. |
0 | |
ReturnWholeMatch | Pass 1 to return whole match including text you have in the pattern. Else pass 0 to get only the text from your captures. | 1 | Optional |
NoReturnEnding | Pass 1 to have no extra newline character on the end of the returned list. Default is 0 to include one to easily concat lists. | 1 | Optional |
Result
Returns list or error.
Description
Finds in a text all matches of a given pattern and returns list.Can be used for example to find tokens or placeholders in a text.
If your search pattern has no captures, please pass 1 for ReturnWholeMatch or you won't see anything in result.
Execute option | Number | Description |
Anchored | 16 | Force pattern anchoring |
Not BOL | 128 | Subject string is not the beginning of a line |
Not EOL | 256 | Subject string is not the end of a line |
Not Empty | 1024 | An empty string is not a valid match |
Partial | 32768 | Allow partial results. |
Newline CR | 1048576 | Set CR as the newline sequence |
Newline LF | 2097152 | Set LF as the newline sequence |
Newline CRLF | 3145728 | Set CRLF as the newline sequence |
Newline Any | 4194304 | Recognize any Unicode newline sequence |
Newline Any CRLF | 5242880 | Recognize CR, LF, and CRLF as newline sequences |
BSR Any CRLF | 8388608 | \R matches only CR, LF, or CRLF |
BSR Unicode | 16777216 | \R matches all Unicode line endings |
No start optimize | 67108864 | Disable match-time start optimizations |
Partial Hard | 134217728 | Return partial result if found before . |
Not Empty At Start | 268435456 | An empty string at the start of the subject is not a valid match |
UCP | 536870912 | Use Unicode properties for \d, \w, etc. |
Please pass sum of the numbers to select options.
Examples
Search for numbers in text:
Set Variable [$regex; Value:MBS("RegEx.Compile"; "(\d+)\D"; 512+1)]
Set Variable [$result; MBS("RegEx.FindMatches"; $regex; "aa 123 abc"; 0; 0)]
Set Variable [$r; Value:MBS("RegEx.Release"; $regex)]
Find cd and 34 in the following text:
Set Variable [$regex; Value:MBS("RegEx.Compile"; "<code>..(..)..</code>"; 512+1)]
Set Variable [$result; Value:MBS("RegEx.FindMatches"; $regex; "<code>abcdef</code>¶<code>123456</code>"; 0; 0)]
Set Variable [$r; Value:MBS("RegEx.Release"; $regex)]
Find matches in multiline text:
Let ([
pattern = "^GR.";
text = "GR1¶GR2 ¶GR3 ";
CompileOptions = 2 /* multiline */ + 1 /* caseless */ + 4194304 /* newline any */;
ExecuteOptions = 4194304 /* newline any */;
regex = MBS("RegEx.Compile"; pattern; CompileOptions );
result = MBS( "RegEx.FindMatches"; regex; text; ExecuteOptions ; 0 );
r = MBS("RegEx.Release"; regex)
]; result )
See also
Release notes
- Version 9.5
- Added NoReturnEnding parameter to RegEx.FindMatches function.
- Version 8.2
- Improved speed for RegEx.FindMatches function a little bit.
Example Databases
Blog Entries
- MBS Plugin Advent calendar: 19 - RegEx
- MBS FileMaker Plugin, version 9.5pr5
- MBS FileMaker Plugin, version 8.2pr2
- MBS FileMaker Plugin, version 7.5pr8
- MBS FileMaker Plugin, version 5.1pr4
- MBS FileMaker Plugin, version 5.1pr1
This function checks for a license.
Created 15th March 2015, last changed 26th April 2023