my random thoughts

The work is always in progress.

  • Main page
  • Posts
  • Nuggets
Skip to content

Tag: regexp

convert glob-style pattern to regular expression in python

2017-10-03 2021-01-20 omik

Python’s fnmatch library makes it easy to convert human-readable glob pattern to re.match()-compatible regexps:

% python3
>>> import fnmatch
>>> fnmatch.translate('dupa.[ch]pp.*')
'dupa\.[ch]pp\..*\Z(?ms)'
>>>
Posted in From 'dev', Programming (and related)Tagged glob, python, regexpLeave a Comment on convert glob-style pattern to regular expression in python

O mnie

picture

Pisze bloga z narzekaniem, marudzeniem na otaczającą rzeczywistość, czasem czymś zdatnym do czytania.
O sobie: MKM, MK, ateista. Typ aspołeczny. Żywi się marudzeniem i całkami. Trzyma w domu (lub nie) kota Schrödingera.

Recent Posts

  • So, I moved.
  • fun fact about TCP
  • (no title)
  • (no title)
  • (no title)

Categories

  • From 'dev'
  • From Tumblr
  • Photography
  • Programming (and related)

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Proudly powered by WordPress | Theme: v92v2 by omik, built upon underscores.me