# matches

## 语法

``TF = matches(str,pat)``
``TF = matches(str,pat,IgnoreCase=true)``

## 说明

``TF = matches(str,pat)` 会在指定模式与 `str` 有匹配时返回 `1` (`true`)，否则返回 `0` (`false`)。如果 `str` 是数组，则 `TF` 是相同大小的数组。如果 `pat` 是包含多个模式的数组，则 `matches` 在发现 `pat` 中任一元素与 `str` 有匹配时将返回 `1`。`

``TF = matches(str,pat,IgnoreCase=true)` 在确定 `pat` 是否与 `str` 有匹配时忽略大小写。`

## 示例

`str = ["Mercury","Venus","Earth","Mars"]`
```str = 1x4 string "Mercury" "Venus" "Earth" "Mars" ```

`TF = matches(str,"Earth")`
```TF = 1x4 logical array 0 0 1 0 ```

`str(TF)`
```ans = "Earth" ```

`str = ["137","0xA7B","0x1248","72","0xG7"]`
```str = 1x5 string "137" "0xA7B" "0x1248" "72" "0xG7" ```

```pat = digitsPattern(1) | characterListPattern("A","F") | characterListPattern("a","f"); pat = "0x" + asManyOfPattern(pat)```
```pat = pattern Matching: "0x" + asManyOfPattern(digitsPattern(1) | characterListPattern("A","F") | characterListPattern("a","f")) ```

`TF = matches(str,pat)`
```TF = 1x5 logical array 0 1 1 0 0 ```

`str(TF)`
```ans = 1x2 string "0xA7B" "0x1248" ```

`str = ["Mercury","Venus","Earth","Mars"]`
```str = 1x4 string "Mercury" "Venus" "Earth" "Mars" ```

`TF = matches(str,["Venus","Earth"])`
```TF = 1x4 logical array 0 1 1 0 ```

`str(TF)`
```ans = 1x2 string "Venus" "Earth" ```

`str = ["Mercury","Venus","Earth","Mars"]`
```str = 1x4 string "Mercury" "Venus" "Earth" "Mars" ```

`TF = matches(str,"earth",IgnoreCase=true)`
```TF = 1x4 logical array 0 0 1 0 ```

`str(TF)`
```ans = "Earth" ```

## 输入参数

• 字符串数组

• 字符向量

• 字符向量元胞数组

• `pattern` 数组（自 R2020b 开始提供）