search

Description

The search() function searches a list for the first element that is found to match a specific pattern. The search is case sensitive and wildcard characters can be used within the pattern.

For more information on using wildcard characters, please see Wildcard Search Characters and quote.

Syntax

result = search (list1, pattern);

Arguments

list1 Required. The list to search.
pattern Required. The pattern to search for.

Return Values

An integer value is returned. If a match is found, then result contains the element number of the first pattern match in the list. If no match is found, result is set to -1.

Example

In this example,

list1 = {"ADM1", "ADM2", "ADM3", "SYSADM1", "SYSADM2", "USER1", "USER2"};
result = search (list1, "SYS*");

result is set to 3 as list1[3] is the first element in the list to match the search pattern.

See Also

append(), insert(), join(), length(), range(), replace()