Skip to main content

re module wrapper for writing regular expressions in functional style

Project description

This is the revival of a small Python module which lived once on the now abandoned Vaults of Parnassus when I entered Python programming about a decade ago. It was originally written and published by JasonHarper in 1998 on a “free for any use” license. Since then it has slowly faded from the net which I find a bit sad.

What is reverb?

reverb.py is a tiny wrapper around Pythons re module which maps regular expressions onto Python expressions for the sake of readability. The module name can be read as “re-verb(ose)”. reverb follows the Python tradition of keeping the amount of punctuation small and avoid punctuation collisions.

In reverb one writes

Optional(Digit)+"."+Required(Digit)

instead of

\d*\.\d+

to denote a pattern that matches a floating point number. The reverb reads much like a meta-language explanation of the dense and compact regexp.

From a reverb object one can fetch the regexp using the text attribute

>>> (Optional(Digit)+"."+Required(Digit)).text
'\\d*\\.\\d+'

Each reverb object translates to a regexp and it is finally the regexp which is compiled and matched against strings.

Reverb in context

I think about reverb any time I encounter a regexp learning tool but also pyparsing which has grown in popularity within the Python community and I suspect it did this for reasons not dissimilar to those intended by reverb: “avoiding line noise when writing regular expressions” in the words of Jason Harper. So I do think it fits a real need.

The only significant change I made to reverb is capitalization of names. reverb 1.0 was published when Python 1.5 came out and used identifiers like any and set which have now counterparts as builtins in Pythons standard library.

Documentation

The complete module documentation can be found here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

reverb-2.0.1.zip (3.4 kB view details)

Uploaded Source

reverb-2.0.1.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file reverb-2.0.1.zip.

File metadata

  • Download URL: reverb-2.0.1.zip
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for reverb-2.0.1.zip
Algorithm Hash digest
SHA256 b65009f7723dac38eb1597dcf691e54cbf2431446f50ece37c3b572decf73ba3
MD5 e04d2d2d359fec9490dccc0d2a4a55fa
BLAKE2b-256 10691800d4345e0562260fa0818f6ac50d2f43d4595f33743c9e2c655709d86d

See more details on using hashes here.

File details

Details for the file reverb-2.0.1.tar.gz.

File metadata

  • Download URL: reverb-2.0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for reverb-2.0.1.tar.gz
Algorithm Hash digest
SHA256 8dda1cc59ee87c0ce7822338bece1c0635319c6227afd718c3ebe296331ddb0e
MD5 ba2bcb5ea344f047839e7d1e3f077a3f
BLAKE2b-256 6a22c45dd56656f2a0e5cc1c4ede1f87a2d8776bb9404c2a20d1718002553da6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page