|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > Split String Commands > String Operations |
STR.StrBetween |
Next |
MiniRobotLanguage (MRL)
STR.StrBetween
Extracts text between start and end delimiters.
Intention
This command finds the first occurrence of a start delimiter and the first occurrence of an end delimiter that appears after it.
It extracts the string of characters located between them.
This command does NOT handle nested structures; for that, use STR.BlockGetFirst.
This command can handle single or multi-character delimiters.
Syntax
STR.StrBetween|P1|P2|P3|P4[|P5][|P6][|P7]
Simple Extraction with STR.StrBetween
Source String: The quick [brown fox] jumps over the lazy dog.
▲ ▲
│ │
Start Delimiter: ---┘ │
│
End Delimiter: -------------┘
Result: "brown fox"
Parameter Explanation
•P1 - (Input, Text) The source string to search within.
•P2 - (Input, Text) The starting delimiter string.
•P3 - (Input, Text) The ending delimiter string.
•P4 - (Output, Text) Variable to store the resulting extracted string.
•P5 - (Input, Numeric) Optional behavior mode for when delimiters are not found.
0 = Return "" (Default)
1 = Return the full source string
2 = Return a partial string if one delimiter is found
•P6 - (Input, Numeric) Optional. If 1, the search is case-insensitive. Default is 0 (case-sensitive).
•P7 - (Output, Numeric) Optional variable to receive a detailed numeric status code.
' Numerical Statuscode
' --- These are BIT FLAGS and can be combined with OR ---
%STR_OK = 0 ' Success, both delimiters were found in order.
%STR_ERR_NO_START = 1 ' The start delimiter was not found.
%STR_ERR_NO_END = 2 ' Start was found, but end was not found after it.
%STR_ERR_BAD_ORDER = 3 ' Both were found, but end appeared before start.
%STR_ERR_EMPTY_DELIM = 4 ' One or both of the delimiters was an empty string.
%STR_WARN_CASE_MISMATCH = 256 ' Success, but delimiters had different casing (requires P6=1).
Example
'***********************************
' STR.StrBetween Example
'***********************************
$$BEG=[BEG]
$$END=[END]
VAR.$$SRC=The quick $$BEGbrown fox$$END jumps over the lazy dog.
STR.StrBetween|$$SRC|$$BEG[$$END|$$RES|0|0|$$LOG
' $$RESULT will now contain "brown fox"
MBX.$$RES$crlf$$$LOG
ENR.
Remarks
-
Limitations:
-
See also:
• STR.BlockGetFirst - Gets the first complete top-level block