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:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
RegEx.FindMatches
Finds in a text all matches of a given pattern and returns list.
| Component | Version | macOS | Windows | Linux | Server | FileMaker 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.Free"; $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.Free"; $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.Free"; regex)
]; result )
See also
Example Databases
Blog Entries
- 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
Release notes
- Version 9.5
- Added NoReturnEnding parameter to RegEx.FindMatches function.
- Version 8.2
- Improved speed for RegEx.FindMatches function a little bit.
Created 15th March 2015, last changed 27th October 2019
Feedback: Report problem or ask question.
Links
MBS Xojo blog