redis-glob-0.1.0.7: Specify valid redis globs
Copyright(c) 2022 Tim Emiola
LicenseBSD3
MaintainerTim Emiola <adetokunbo@emio.la>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Redis.Glob

Description

Provides functions to validate and use redis glob patterns.

Assumes that the non-printable ASCII characters are not matched.

Synopsis

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

Expand
>>> 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

Expand
>>> "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