length()

Return the number of characters in a string.

Syntax

length(text)

Parameter

Parameter

Definition

text

text to be counted for character length The text can be a text string enclosed in double quotation marks, or one or more PSL commands that produce text as output.

Description

The length() function returns the length in characters of text, including new lines. This function differs from num_bytes(), which returns the length of a string in bytes. Due to international codesets, one or more bytes can form a single character.

Example

The following length() function call returns the number of characters in a string:

X = "28 characters in this string";
List = ["red", "green", "blue"];
print(length(List), " Length of list\n");
print(length(X)," Length of string \n");


Was this page helpful? Yes No Submitting... Thank you

Comments