TF = matches(str,pat)
returns 1 (true) if the specified pattern matches
str, and returns 0 (false)
otherwise. If str is an array, then TF is an array of
the same size.
If pat is an array containing multiple patterns, then
matches returns 1 if it finds that any element of
pat matches str.
Find the strings that match "Earth". Return a logical array where the position of each element equal to 1 corresponds to the position of a matching string in str.
TF = matches(str,"Earth")
TF = 1x4 logical array
0 0 1 0
Display the match by indexing back into str using TF.
Create a pattern that matches the hexadecimal numbers. To match a single hexadecimal digit, specify a pattern that matches any digit, any capital letter A-F, or any lowercase letter a-f. Then, specify a pattern that begins with 0x and is followed by any number of hexadecimal digits.
pat = digitsPattern(1) | characterListPattern("A","F") | characterListPattern("a","f");
pat = "0x" + asManyOfPattern(pat)
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.