Skip to content

String functions

String functions operate on ANY_STRING (STRING, WSTRING); a few accept ANY_CHARS (also CHAR/WCHAR) for the search/replace fragment. Character positions are 1-based — the first character is at position 1, and FIND returns 0 when the substring is not present.

FunctionParametersReturns
LENIN : ANY_STRINGINT
LEFTIN : ANY_STRING, L : ANY_INTANY_STRING
RIGHTIN : ANY_STRING, L : ANY_INTANY_STRING
MIDIN : ANY_STRING, L : ANY_INT, P : ANY_INTANY_STRING
CONCATIN : ANY_STRING (2+ args)ANY_STRING
INSERTIN1 : ANY_STRING, IN2 : ANY_STRING, P : ANY_INTANY_STRING
DELETEIN : ANY_STRING, L : ANY_INT, P : ANY_INTANY_STRING
REPLACEIN1 : ANY_STRING, IN2 : ANY_CHARS, L : ANY_INT, P : ANY_INTANY_STRING
FINDIN1 : ANY_STRING, IN2 : ANY_CHARSANY_INT
LEN(IN : ANY_STRING) : INT
n := LEN('Hello'); // 5

LEFT, RIGHT — leading / trailing substring

Section titled “LEFT, RIGHT — leading / trailing substring”

Return the first / last L characters of IN.

LEFT(IN : ANY_STRING, L : ANY_INT) : ANY_STRING
RIGHT(IN : ANY_STRING, L : ANY_INT) : ANY_STRING
prefix := LEFT(code, 3); // first 3 characters
suffix := RIGHT(code, 2); // last 2 characters
MID(IN : ANY_STRING, L : ANY_INT, P : ANY_INT) : ANY_STRING

Returns L characters from IN starting at 1-based position P.

middle := MID('ABCDEF', 3, 2); // 'CDE' starts at position 2 -> 'CDE'

CONCAT is variadic (two or more inputs).

CONCAT(IN : ANY_STRING, ...) : ANY_STRING // 2+ args
greeting := CONCAT('Hello, ', name, '!');
INSERT(IN1 : ANY_STRING, IN2 : ANY_STRING, P : ANY_INT) : ANY_STRING

Inserts IN2 into IN1 after 1-based position P.

result := INSERT('ABEF', 'CD', 2); // 'ABCDEF'
DELETE(IN : ANY_STRING, L : ANY_INT, P : ANY_INT) : ANY_STRING

Removes L characters from IN starting at 1-based position P.

trimmed := DELETE('ABCDEF', 2, 3); // remove 'CD' -> 'ABEF'
REPLACE(IN1 : ANY_STRING, IN2 : ANY_CHARS, L : ANY_INT, P : ANY_INT) : ANY_STRING

Replaces L characters of IN1 starting at 1-based position P with IN2.

fixed := REPLACE('ABCDEF', 'XY', 2, 3); // replace 'CD' -> 'ABXYEF'
FIND(IN1 : ANY_STRING, IN2 : ANY_CHARS) : ANY_INT

Returns the 1-based position of the first occurrence of IN2 within IN1, or 0 if it is not found.

pos := FIND(line, 'ERROR'); // 0 when not present
IF pos > 0 THEN
// handle the error marker
END_IF