Skip to main content

Ultra-simple human readable DSL for matching text.

Project description

SimEx is a substitute for regular expressions that lets you write non-developer readable/writeable matching expressions.

It is sometimes, but not always, more suitable than writing regular expressions directly.

To install:

$ pip install simex

To use:

>>> from simex import simex
>>> LINK_EXPRESSION = """<a href="{{ url }}">{{ anything }}</a>"""
>>> exp = simex(LINK_EXPRESSION, regexes={"url": r"(.*?)", "anything": r".*?"})
>>> exp.match("""<a href="http://www.cnn.com">CNN</a>""") is not None
True

>>> exp = simex(LINK_EXPRESSION, regexes={"url": r"(.*?)"})
>>> exp.match("""<a href="http://www.cnn.com">{{ anything }}</a>""") is not None
True

>>> exp = simex(LINK_EXPRESSION, regexes={"url": r"(.*?)"})
>>> exp.search("""Pre text <a href="http://x.com">{{ anything }}</a> post text""") is not None
True

Project details


Download files

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

Source Distribution

simex-0.2.0.tar.gz (2.4 kB view hashes)

Uploaded Source

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