String Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > String commands > !STR.- String Command > String Replace Commands >

String Operations

STR.Replace / STR.Rpl

Previous Top Next


MiniRobotLanguage (MRL)

 

STR.Replace

Replace All Occurrences of a Substring in a String

 

clip0839

Replace apple with oranges.

 

 

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

The replacement is done directly in  the source string.

 

 

 

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'

MBX.$$SRC

ENR.

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also: