|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > Split String Commands > String Operations |
MiniRobotLanguage (MRL)
STR.StrBetween
Extracts text between two delimiters (content only).
Intention
This Command extracts the text that lies between two specified delimiters. It is similar to STR.Extract but optimized for the common use case of getting content between tags or markers.
Unlike BLO commands, this does not handle nesting - it finds the first occurrence of the start delimiter and the first following occurrence of the end delimiter.
Syntax
STR.StrBetween|P1|P2|P3|P4
Parameter Explanation
•P1 - (Input, Text) The source string to search.
•P2 - (Input, Text) The starting delimiter (left boundary).
•P3 - (Input, Text) The ending delimiter (right boundary).
•P4 - (Output, Text) Variable to store the extracted content (between delimiters).
Extracting Text Between Delimiters
Source: "Name: [John] Age: 30"
Start: "[", End: "]"
Result: "John"
Source: "<div>Hello World</div>"
Start: "<div>", End: "</div>"
Result: "Hello World"
Example
'***********************************
' STR.StrBetween Example
'***********************************
$$HTML="<title>My Page</title>"
' Extract the title text
STR.StrBetween|$$HTML|<title>|</title>|$$TITLE
' $$TITLE = "My Page"
MBX.Page title: $$TITLE
' Parse key-value pairs
$$PAIR="Key: {{Value}}"
STR.StrBetween|$$PAIR|{{|}}|$$VALUE
' $$VALUE = "Value"
' Extract from parentheses
$$EXPR="Result: (42) points"
STR.StrBetween|$$EXPR|(|)|$$NUM
' $$NUM = "42"
MBX.$$NUM
ENR.
Remarks
? Only the first occurrence of the delimiters is processed.
? The delimiters themselves are not included in the result.
? If delimiters are not found, an empty string is returned.
? For nested block extraction with proper pairing, use BLO.BlockGetFirst instead.
See also:
? STR.Extract - Extract between delimiters (alias)
? BLO.GetFirst - Get block with nesting support
? STR.GrabBetween - Extract with advanced options