Documentation

util.strings.match

Match a string to a pattern using a unix-like filesystem's pattern matching.

  • *: Match anything
  • ?: Match any single character
  • [seq]: Match any characters in seq
  • [!seq]: Match any characters not in seq

Arguments:

def util.strings.match(
  test: str = None,
  s: str = None,
):

Returns a boolean.

Example:

util.strings.match(s="foo", test="f*") # True
util.strings.match(s="foo", test="d*") # False
util.strings.match(s="foo", test="f??") # True
util.strings.match(s="foo", test="y??") # False
util.strings.match(s='fzo', test='f[a-z][o]') # True
util.strings.match(s='fzo', test='f[abc][o]') # False
util.strings.match(s='fao', test='f[abc][o]') # False
util.strings.match(s='foo', test='f[!abc][o]') # True
util.strings.match(s='foo', test='f[!a-z][o]') # False
util.strings.match(s='f1o', test='f[!a-z][o]') # True