matches
Determine if pattern matches with strings.
📝Syntax
res = matches(str, pattern)
res = matches(str, pattern, 'IgnoreCase', true)
📥Input Arguments
Parameter Description
str a string, string array, cell of strings or categorical array.
pattern a string, string array or cell of strings.
📤Output Arguments
Parameter Description
res a logical: true if the two matches and false otherwise.
📄Description

matches determines if pattern matches with strings.

If str is a categorical array, matches tests the category name of each element and returns a logical array of the same size. Undefined elements return false. pattern cannot be categorical.

💡Examples
matches("Nelson", 'nelSon')
matches("Nelson", 'Nelson')
str = ["yellow", "green", "blue", "brown"];
R = matches(str, ["yellow", "Brown"], 'IgnoreCase', true);
Pattern matching on the category names of a categorical array.
C = categorical({'winter storm', 'fire', 'Thunder Storm', ''});
tf = matches(C, "FIRE", 'IgnoreCase', true)
🔗See Also
strcmpcategorical
🕔Version History
Version Description
1.0.0 initial version
2.0.0 categorical array accepted as str input.
Edit this page on GitHub