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
Release history Release notifications | RSS feed
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)
Built Distribution
ezptn-0.0.1-py3-none-any.whl
(3.2 kB
view hashes)