> For the complete documentation index, see [llms.txt](https://docs.cheddar.vihan.org/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cheddar.vihan.org/docs/standard-library/string/match.md).

# Match

| type   | returns         |
| ------ | --------------- |
| Method | `array<string>` |

## Arguments

| name  | type  | description           |
| ----- | ----- | --------------------- |
| regex | regex | Regex to match string |

## Explanation

Returns an array of matched strings. When and if the `g` flag is provided, `.match()` returns all the matches in the string. Regardless of flags, `.match()` will always return a string array.

## Examples

```swift
"Hello! Hi!".match(/H.+?!/) == ["Hello!"]
"Hello! Hi!".match(/H.+?!/g) == ["Hello!", "Hi!"]
```
