Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5   7.6    Statistic  

RegEx.FindMatches

Finds in a text all matches of a given pattern and returns list.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
RegEx 5.1 Yes Yes Yes Yes Yes

MBS( "RegEx.FindMatches"; RegExRef; Text; ExecuteOptions { ; ReturnWholeMatch } )

Parameters

Parameter Description Example value
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 Optional
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

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 optionNumberDescription
Anchored16Force pattern anchoring
Not BOL128Subject string is not the beginning of a line
Not EOL256Subject string is not the end of a line
Not Empty1024An empty string is not a valid match
Partial32768Allow partial results.
Newline CR1048576Set CR as the newline sequence
Newline LF2097152Set LF as the newline sequence
Newline CRLF3145728Set CRLF as the newline sequence
Newline Any4194304Recognize any Unicode newline sequence
Newline Any CRLF5242880Recognize CR, LF, and CRLF as newline sequences
BSR Any CRLF8388608\R matches only CR, LF, or CRLF
BSR Unicode16777216\R matches all Unicode line endings
No start optimize67108864Disable match-time start optimizations
Partial Hard134217728Return partial result if found before .
Not Empty At Start268435456An empty string at the start of the subject is not a valid match
UCP536870912Use 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


RegEx.Execute   -   RegEx.Free

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins