Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

strmatch - Find possible matches for string

Syntax

x = strmatch(str, strarray)
x = strmatch(str, strarray, 'exact')

Description

x = strmatch(str, strarray) looks through the rows of the character array or cell array of strings strarray to find strings that begin with the text contained in str, and returns the matching row indices. Any trailing space characters in str or strarray are ignored when matching. strmatch is fastest when strarray is a character array.

x = strmatch(str, strarray, 'exact') compares str with each row of strarray, looking for an exact match of the entire strings. Any trailing space characters in str or strarray are ignored when matching.

Examples

The statement

x = strmatch('max', strvcat('max', 'minimax', 'maximum'))

returns x = [1; 3] since rows 1 and 3 begin with 'max'. The statement

x = strmatch('max', strvcat('max', 'minimax', 'maximum'),'exact')

returns x = 1, since only row 1 matches 'max' exactly.

See Also

strcmp, strcmpi, strncmp, strncmpi, strfind, findstr, strvcat, regexp, regexpi, regexprep

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS