index()

Return the starting position of one string within another.

Syntax

index(text,string)

Parameter

Parameter

Definition

text

text to be searched for the occurrence of string The text can be a text string enclosed in double quotation marks, or one or more PSL commands that produce text as output.

string

one or more characters enclosed in double quotation marks that are to be located within text.

Description

The index() function returns the position (indicated as an integer) in text at which string begins, or 0 if string does not occur in text. The first position in text is position 1.

Example

The following PSL statement uses the index() function to find the position of one string within another:

sentence = "The quick red fox jumped over the lazy brown dogs";
animal = "fox";
print(index(sentence,animal));


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

Comments