data_helper.regex module

Regular expressions wrapper functions to streamline common use cases

data_helper.regex.wildcard_re(pattern, wildcard='*', escape='\\')[source]

Transform a wildcard pattern to a regular expressions pattern

Alphanumeric characters are preserved. All other characters are escaped except for asterisk which is replaced with ‘.*’

Parameters:
  • pattern (str) – String of wildcard pattern.
  • wildcard (str) – Wildcard symbol. Defaults to ‘*’
  • escape (str) – Character escape symbol (must be a Python string literal). Defaults to ‘’
Returns:

Regular expressions pattern.

Return type:

str