PyDocs

Nav

File and Directory Access

translate

fnmatch

function (source)
  • translate(pat)
Translate a shell PATTERN to a regular expression.

There is no way to quote meta-characters.
1 Example
>>> import fnmatch, re
>>>
>>> regex = fnmatch.translate('*.txt')
>>> regex
'(?s:.*\\.txt)\\z'
>>> reobj = re.compile(regex)
>>> reobj.prefixmatch('foobar.txt')
<re.Match object; span=(0, 10), match='foobar.txt'>
from the Python docs
See Also
No see-alsos for fnmatch/translate
0 Notes
No notes for translate