Skip to main content

String pattern matching with placeholders.

Project description

ezptn

Overview

  • String pattern matching with placeholders.
  • プレースホルダーを使った文字列パターンマッチ

Usage

import ezptn

res = ezptn.match("lambda %s: %s", "lambda a: a ** 2")
print(res)	# -> [('a', 'a ** 2')]
res = ezptn.match("%s:%s", "13:12:24")
print(res)	# -> [('13', '12:24'), ('13:12', '24')]
res = ezptn.match("%s--%s", "hoge-fuga")
print(res)	# -> []
res = ezptn.match("%squid", "equid")
print(res)	# -> [('e',)]
res = ezptn.match("%s(%s)", "hoge(22)")
print(res)	# -> [('hoge', '22')]
res = ezptn.match("%s(%s)", "hoge()")
print(res)	# -> [('hoge', '')]
res = ezptn.match("%s(%s)", "hoge()", allow_empty = False)
print(res)	# -> []
res = ezptn.match("(%s,((%s,%s),%s))", '(23,(("s",44),44))')
print(res)	# -> [('23', '"s"', '44', '44')]

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

ezptn-0.0.1.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

ezptn-0.0.1-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

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