strmatch

strmatch checks if elements of a string matrix match a pattern.

rmBool = strmatch(ssPattern, smString)

Return Value

rmBool is real matrix. A matrix element of rmBool is True (1), if the corresponding string element of smString matches the pattern ssPattern, and False (0), if the corresponding element of smString does not match the pattern.

Parameters

ssPattern

ssPattern is a scalar string containing a pattern.

Value Meaning
* Match zero or more characters.
? Match any single character.
[SET] Matches any character in the specified set.
[!SET] or [^SET] Matches any character not in the specified set. For example, the pattern [aAbB] or [0-9A-Z] will match the numbers 0 to 9 and all upper case alphabetic characters. If any of the characters []*?!^-are used in [SET], a double backslash “"
smString

smString is a string matrix.

Comment

A set is composed of characters or ranges; a range looks like character hyphen character (as in 0-9 or A-Z). [0-9a-zA-Z_] is the minimal set of characters allowed in the [..] pattern construct.

To suppress the special syntactic significance of any of []*?!^-\, and match the character exactly, precede it with a \\.

Example

The following example shows how to find out if a string contains small letters.

* strmatch("*[a-z]*", ["Hallo", "HALLO"])
    1.0000       0.0000

Example

* strmatch("hello", "hello")
    1.0000
* strmatch("hello", "Hello")
    0.0000
* strmatch("[hH]ello", "Hello")
    1.0000
* strmatch("*ello", "Hello")
    1.0000
* strmatch("*el?o", "Hello")
    1.0000
* what("strm*")
strmatch
  1 function(s) defined
* what("str[!m]*")
strchar
strCharToOem
strcode
strempty
strfindreplace
strlen
strlower
strOemToChar
strsplit
strtod
strtofield
strtok
strtrim
strupper
  14 function(s) defined
* strmatch("*\*\*CHAN[0-9]\*\**", ["asdf**CHAN1**asdf", "asdf"])
    1.0000    0.0000

id-1415657