Template

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Template

STR.GetNested

Previous Top Next


MiniRobotLanguage (MRL)

 

STR.GetNested

Extracts a Nested Substring Between Delimiters at a Specific Nesting Level

 

 

Intention

 

This command extracts a nested sub string 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).

 

 

Example usage:

 

You are parsing this MQL5-code and you want the content between { and } including all nested { } inside.

This command will count the nesting level and return exactly the Part that you want (yellow).

 

void DeinitializeTradeInfoDisplay()

{

   for (int i = 0; i < 8; i++)

   {

      ObjectDelete(0, OBJ_LABEL_PREFIX + "Label" + IntegerToString(i));

      ObjectDelete(0, OBJ_LABEL_PREFIX + "Value" + IntegerToString(i));

   }

 

   // Delete buttons

}

 

 

 

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: