mwilliamson / python-precisely

Matcher library for Python
BSD 2-Clause "Simplified" License
238 stars 11 forks source link

Regex matcher? #16

Open davified opened 2 years ago

davified commented 2 years ago

Hi there, thanks for the great work on this library!

I was wondering if there's a way to do regex matching with the existing API?

# existing API
assert_that("1975-09-24", contains_string('1975-09-24'))

# is there a matcher that allows something like this?
assert_that("hello", matches_regex(r'[\d]{4}-[\d]{2}-[\d]{2}'))

Thanks!

mwilliamson commented 2 years ago

I don't see why not. If you take a look at the implementation of contains_string(), that should point you in the right direction.