<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > String Operations |
MiniRobotLanguage (MRL)
STR.Replace
Replace All Occurrences of a Substring in a String
Intention
This command is used to replace all occurrences of a specified substring P2 with another string P3 within the main string P1.
•The replacement is case-sensitive.
•The scan for the next match begins at the position immediately following the prior match.
•The replacement can cause the main string to grow or condense in size.
Syntax
STR.Replace|P1|P2|P3
STR.Rpl|P1|P2|P3
Parameter Explanation
•P1 - (Mainstring, Text) Variable containing the source string.
•P2 - (MatchString, Text) String containing the substring to be replaced.
•P3 - (NewString, Text) String containing the characters to replace with.
Example
'***********************************
' STR.-Sample
'***********************************
' Replace all occurrences of 'apple' with 'orange' in the string
$$SRC=apple apple apple
$$MAT=apple
$$NEW=orange
STR.Replace|$$SRC|$$MAT|$$NEW
$$SRC will now contain 'orange orange orange'
ENR.
Remarks
-
Limitations:
-
See also:
•