Navigation

Operators and Keywords

Function List:

C++ API

: strmatch (s, A)
: strmatch (s, A, "exact")

Return indices of entries of A which begin with the string s.

The second argument A must be a string, character matrix, or a cell array of strings.

If the third argument "exact" is not given, then s only needs to match A up to the length of s. Trailing spaces and nulls in s and A are ignored when matching.

For example:

strmatch ("apple", "apple juice")
     ⇒ 1

strmatch ("apple", ["apple  "; "apple juice"; "an apple"])
     ⇒ [1; 2]

strmatch ("apple", ["apple  "; "apple juice"; "an apple"], "exact")
     ⇒ [1]

Caution: strmatch is scheduled for deprecation. Use strncmp (normal case), or strcmp ("exact" case), or regexp in all new code.

See also: strfind, findstr, strcmp, strncmp, strcmpi, strncmpi, find.

Package: octave