Shouldly
  • Overview
  • Contributing
  • Documentation
    • Getting Started
    • Configuration
    • Equality
      • ShouldBe
      • NotBe
      • Null
      • Bool
      • Flags
      • AssignableTo
      • OfType
      • OneOf
      • Greater/Less Than
      • InRange
      • MatchApproved
      • Enumerable
      • SameAs
      • String
      • ExampleClasses
    • String
      • ShouldBe
      • Match
      • Contain
      • Null and Empty
      • StartWith
      • EndWith
    • Enumerable
      • ShouldBe
      • All
      • Empty
      • OneOf
      • Contain
      • Unique
      • SubsetOf
      • Have
    • Dictionary
      • ContainKey
      • ContainKeyAndValue
    • Exceptions
      • Throw
      • NotThrow
    • SatisfyAllConditions
    • CompleteIn
    • DynamicShould
    • Upgrade 3 to 4
Powered by GitBook
On this page
  • ShouldMatch
  • ShouldNotMatch
Edit on GitHub
  1. Documentation
  2. String

Match

PreviousStringNextContain

Last updated 2 years ago

ShouldMatch

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

|

Exception

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

ShouldNotMatch

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

|

Exception

target should not match "Homer .*" but did
snippet source
snippet source
anchor
anchor