Next Page Contents

stringlib::contains -- test for substring

Introduction

With stringlib::contains a string can be tested whether it contains another string.

Call(s)

stringlib::contains(string1, string2 <, option>)

Parameters

string1, string2 - non empty string

Options

Index - causes the first index position at which string2 appears in string1 to be returned. The return value is 0 if string2 occurs nowhere in string1.
IndexList - causes the list of all positions at which string2 appears in string1 to be returned. The returned list may be empty.

Returns

TRUE, if string1 contains string2, otherwise FALSE. An integer (or a list of integers) that determines the position, if an option is given.

Related Functions

contains, stringlib::pos

Details

Example 1

If called without options, stringlib::contains simply returns TRUE or FALSE.

>> stringlib::contains("abcdeabcdeabcde", "bc")
                                   TRUE
>> stringlib::contains("abcdeabcdeabcde", "bc", Index)
                                     1
>> stringlib::contains("abcdeabcdeabcde", "bc", IndexList)
                                [1, 6, 11]

Example 2

The following call does not return [0,1] because the first matching substring has not ended when the second begins.

>> stringlib::contains("aaa", "aa", IndexList)
                                    [0]

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000