Copyright | (c) 2022 Tim Emiola |
---|---|
License | BSD3 |
Maintainer | Tim Emiola <adetokunbo@emio.la> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Provides functions to validate and use redis glob
patterns.
Assumes that the non-printable ASCII characters are not matched.
Synopsis
- validate :: ByteString -> Maybe ByteString
- matches :: ByteString -> ByteString -> Bool
validate and match using redis globs
validate :: ByteString -> Maybe ByteString Source #
Confirm that a glob pattern
is valid
the result is:
- Nothing
when the pattern is invalid
- Just norm
, where norm is a normalized version of the pattern
Examples
>>>
validate "hel?o"
Just "hel?o"
>>>
validate "hel[i-m]o"
Just "hel[i-m]o"
>>>
validate "hell[i-]o"
Nothing
matches :: ByteString -> ByteString -> Bool Source #
Confirm that a target
ByteString
matches the pattern
defined by another.
the result is:
- False
when the pattern is invalid or does not match target
- otherwise it's True
Examples
>>>
"hello" `matches` "hel?o"
True
>>>
"hello world" `matches` "[^m-z]el[i-m]o w*"
True
>>>
"yello world" `matches` "[^m-z]el[i-m]o w???d"
False