String Operations

<< Click to Display Table of Contents >>

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

String Operations

STR.Delete

Previous Top Next


MiniRobotLanguage (MRL)

 

STR.Delete

Deletes a range of characters from a string.

 

 

 

Intention

 

This Command removes a specified range of characters from a string by position. You provide the starting position and the ending position, and everything in between (inclusive) is removed.

This is useful for removing specific sections of text when you know the exact character positions.

 

 

Syntax

 

STR.Delete|P1|P2|P3|P4

 

Parameter Explanation

 

P1 - (Input, Text) The source string to modify.

P2 - (Input, Numeric) The starting position (1-based) of the range to delete.

P3 - (Input, Numeric) The ending position (1-based) of the range to delete.

P4 - (Output, Text) Variable to store the resulting string.

 

 

 Deleting a Character Range

 

 1 5 10 15 20

Source String: "Hello World Example"

 +-----+

Delete from 7 to 11: ^^^^^

 

Result: "Hello Example"

 

 

 

Example

 

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

' STR.Delete Example

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

$$SRC="Hello World Example"

' Delete "World " (positions 7-12)

STR.Delete|$$SRC|7|12|$$RES

' $$RES = "Hello Example"

MBX.$$RES

 

' Delete first 6 characters

$$TEXT="Remove this part|Keep this"

STR.Delete|$$TEXT|1|16|$$RESULT

' $$RESULT = "Keep this"

MBX.$$RESULT

ENR.

 

Remarks

 

? If P2 > P3, the parameters are automatically swapped.

? If P2 < 1, it is treated as 1. If P3 > length of string, it is treated as the string length.

? For deleting by delimiter rather than position, use STR.ClipMid or STR.Remove.

 

See also:

 

? STR.DeleteTo - Delete from position to end

? STR.ClipMid - Remove middle section

? STR.Remove - Remove by substring match