Previous Page Next Page Contents

stringlib::pos -- Position of a substring

Introduction

stringlib::pos returns the position of a substring in a string.

Call(s)

stringlib::pos(string1, string2 <, pos>)

Parameters

string1, string2 - non empty string
pos - integer that determines the first position to search

Returns

An integer that determines the position or FAIL.

Related Functions

stringlib::contains, length

Details

Example 1

In case of several occurrences of the substring, the position of the first is returned.

>> stringlib::pos("abcdeabcdeabcde", "bc")
                                     1

Example 2

If a starting point for the search is given, stringlib::pos returns the first position at which the substring occurs after that starting point.

>> stringlib::pos("abcdeabcdeabcde", "bc", 5)
                                     6

Example 3

The result is FAIL if the substring does not occur at all or after the given starting point.

>> stringlib::pos("abcdeabcdeabcde", "bc", 12)
                                   FAIL

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000