<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > String Operations |
MiniRobotLanguage (MRL)
STR.XNInstr
Finds the Nth Occurrence of a String Starting from a Given Position
This is the result from the Sample Script below.
Intention
This command is used to find the Nth occurrence of a specified string (P2) in a source string (P1), starting from a given character position (P4).
The result is placed on the Top of Stack (TOS) or in an optional variable (P5).
Syntax
STR.XNInstr|P1|P2|P3|P4[|P5]
Parameter Explanation
•P1 - (Source String) The main string in which to search for the specified string.
•P2 - (Search String) The string to search for.
•P3 - (Occurrence Number) The Nth occurrence of the search string to find.
•P4 - (Start Position) The character position to start the search from.
•P5 - (Optional) Variable for storing the result. If omitted, the result is placed on TOS.
Example
'***********************************
' IRS.-Sample
'***********************************
$$SRC=<HelloWorldHelloWorld>
$$SCH=Hello
$$OCC=2
$$POS=6
STR.XNINSTR|$$SRC|$$SCH|$$OCC|$$POS
' Result on TOS:
' Position where the 2nd occurrence of 'Hello' is found starting from position 6.
ENR.
Remarks
-
Limitations:
-
See also:
•