String Operations

<< Click to Display Table of Contents >>

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

String Operations

STR.CiRetain

Previous Top Next

 


MiniRobotLanguage (MRL)

 

STR.CiRetain

Retains Specified Substrings in a String (Case-Insensitive)

 

clip1132

Keep only defined substrings, ignoring case.

 

 

Intention

 

This command is used to retain only the characters in the source string that are part of exact substring matches with one or more specified match strings, ignoring case differences. All other characters are removed. The command processes multiple match strings sequentially, and once a character is retained as part of a match, it is ignored for subsequent matches to prevent overlapping or re-marking. Unlike STR.Retain, this variant performs case-insensitive matching.

The command is case-insensitive.

Each match string is searched for in the source string (case-insensitively), and only the first valid match for each character position is retained.

Subsequent matches that include already-retained characters are ignored.

The result contains only the characters that are part of the matching substrings, in their original order and case from the source string.

Overlapping matches are resolved by retaining the first valid match for each character position.

 

 

Syntax

 

STR.CiRetain|P1|P2[|P3[|...|Pn]]

STR.CiRtn|P1|P2[|P3[|...|Pn]]

 

 

Parameter Explanation

 

P1 - (Source String) The main string from which to retain substrings. Modified directly unless Pn is a result variable.

P2 - (Match String) The first substring to be retained (case-insensitive).

P3...Pn - (Optional Match Strings or Result Variable) Additional substrings to retain (case-insensitive), or the variable to store the result. If the last parameter is a variable, the result is stored there; otherwise, P1 is modified.

 

 

Example

 

'***********************************

' STR.Retain - Sample

'***********************************

$$SRC=HelloWorldTestFooBar

STR.CiRetain|$$SRC|HELLO|loWo|Foo

MBX.$$SRC

ENR.

 

Remarks

- The command processes match strings in order, retaining characters from the first valid case-insensitive match at each position.

- If no matches are found, the result is an empty string.

- Empty match strings are ignored.

- The retained characters maintain their original case from the source string.

 

Limitations:

- Always case-insensitive; no case-sensitive mode available in this variant.

- Overlapping matches are resolved by retaining the first valid match for each character position.

 

See also:

STR.Retain

STR.Replace