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

# Match

## ShouldMatch

```cs
var target = "Homer Simpson";
target.ShouldMatch("Bart .*");
```

[snippet source](https://github.com/shouldly/shouldly/blob/master/src/DocumentationExamples/CodeExamples/StringExamples.ShouldMatch.codeSample.approved.cs#L1-L2) | [anchor](#snippet-StringExamples.ShouldMatch.codeSample.approved.cs)

**Exception**

```
target
    should match
"Bart .*"
    but was
"Homer Simpson"
```

## ShouldNotMatch

```cs
var target = "Homer Simpson";
target.ShouldNotMatch("Homer .*");
```

[snippet source](https://github.com/shouldly/shouldly/blob/master/src/DocumentationExamples/CodeExamples/StringExamples.ShouldNotMatch.codeSample.approved.cs#L1-L2) | [anchor](#snippet-StringExamples.ShouldNotMatch.codeSample.approved.cs)

**Exception**

```
target should not match "Homer .*" but did
```
