Description

Searches an array of strings to find those which match a supplied template.

Return Type

A McObject object.  

A sector for those strings in the ListArray that match the supplied TemplateString.

Syntax

object.McLookupInList (TemplateString, ListArray, [OptionFlags])

The McLookupInList Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McOMGlobal.
TemplateStringRequired. A String value.

A template to look up in the list of strings

ListArrayRequired. A Variant value.

The array of strings to test.

OptionFlagsOptional. A mcobjTextMatchFlags enumeration, as described in settings.

Flags to control whether the TemplateString is to be interpreted as a regular expression or not, and whether case should be ignored in the lookup.

Settings

The settings for OptionFlags are:

ConstantValueDescription
 mcobjNoRegExprAndMatchCase0
 mcobjAllowRegularExpression1

allow regular expression match

 mcobjIgnoreCase2

ignore case when doing match

 mcobjMatchWholeWords4

Match whole words

 mcobjMatchAcrossEndOfLine8

The . wild-card character can match across an end-of-line

 mcobjMatchEntireString16

Match template to entire string rather that the first match

Remarks

The function returns a selector for those strings which match the template. A “selector” is an integral array that has positive index values representing selected, or “true”, elements and negative, -(index+1), values representing unselected, or “false”, elements. Selectors can be passed in as arguments to the the McObject.SelectedValues property to extract or assign to a sub-array containing only selected elements from an array or matrix.

The template string can optionally contain a “regular-expression” similar to that used by the UNIX grep utility. If the “enable regular expression” option is selected, the template string can contain special wild card characters according to the following rules:

. A dot (period) matches any single character.

[abc]   A group of characters enclosed in brackets matches any character within
the brackets.  The brackets may contain ranges; for example, [a-z] matches any
letter from a through z (A through Z will also match if the “ignore case” option
is selected).

[^abc] A group of characters enclosed in brackets and beginning with the ^ character, matches any character not listed within the brackets. The brackets may contain ranges; for example, [^a-z] matches any character other than a lower case letter (upper case letters will also fail to match if the “ignore case” option is selected).

The character or any one of a bracketed group of characters preceding a character is matched zero or more times.

^ and $ match the beginning of a line (following a line-feed character, \n) or end-of-line (a carriage-return \r, a \n, or end of row), respectively.

< and > match the beginning or end of a word, respectively (a word consists of letters, numbers or underscore only).

The backslash, \, is the escape character; it undoes the special meanings of the above characters. Since the backslash is also ALI's escape character, you will need to put in \\ pairs to get one backslash within a quoted string.

Any other character matches only that character.

Notes

The UNIX grep utility uses \< and \> instead of < and > for begin/end word in regular expressions. Currently, we do not support the grep group-reference construct \digit within reqular expression templates.