<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > Template |
MiniRobotLanguage (MRL)
STR.GetNested
Extracts a Nested Substring Between Delimiters at a Specific Nesting Level
Intention
This command extracts a nested substring from a source string (P1) that is enclosed between a specified starting delimiter (P2) and ending delimiter (P3) at a given nesting level (P4).
The result is either placed on the Top of Stack (TOS) or in an optional variable (P5).
Syntax
STR.GetNested|P1|P2|P3[|P4][|P5]
Parameter Explanation
•P1 - (Source String) The string from which to extract the nested substring.
•P2 - (Starting Delimiter) The character or string that marks the beginning of the nested substring to extract.
•P3 - (Ending Delimiter) The character or string that marks the end of the nested substring to extract.
If you omit P3, the System will automatically know some fitting Ending delimiters for P2,
like: <>,(),[],{} in all other cases it will assume that P3 = P2.
•P4 - (Nesting Level, default 2l) The level of nesting to consider when extracting the nested substring.
•P5 - (Optional) Variable for storing the result. If omitted, the result is placed on TOS.
Example
'***********************************
' STR.-Sample
'***********************************
$$SRC=((Hello(World(new))))
$$STA=(
$$ENA=)
$$LVA=1
STR.GetNested|$$SRC|$$STA|$$ENA|$$LVA|$$REA
$$LVA=2
STR.GetNested|$$SRC|$$STA|$$ENA|$$LVA|$$REB
$$LVA=3
STR.GetNested|$$SRC|$$STA|$$ENA|$$LVA|$$REC
DBP.$$REA$crlf$ $$REC$crlf$ $$REB
ENR.
' Output will be:
(Hello(World(new)))
World(new)
Hello(World(new))
Remarks
-
Limitations:
-
See also:
•