- 授权协议: Apache
- 开发语言: Python
- 操作系统: Linux
- 软件首页: https://github.com/google/sre_yield
软件介绍
sre_yield 是用于生成正则表达式匹配结果的 Python 模块,并尽可能的匹配到所有有效值。它采用了解析正则表达式的方式,所以你可以得到一个更加精确的结果,而不仅仅只是分散的字符串。
sre_yield 通常都无法处理反向引用、lookarounds 正则表达式,除此之外,还有在这几种情况下也无法处理;
The maximum value for repeats is system-dependant -- CPython's
sremodule there's a special value which is treated as infinite (either 2**16-1 or 2**32-1 depending on build). In sre_yield, this is taken as a literal, rather than infinite, thus (on a 2**16-1 platform):The
remodule docs say "Regular expression pattern strings may not contain null bytes" yet this appears to work fine.Order does not depend on greediness.
The regex is treated as fullmatch.
sre_yieldis confused by even the simplest of anchors:
代码示例:
>>> import random
>>> v = sre_yield.AllStrings('[abc]{1,4}')
>>> len(v)
120
# Now random.choice(v) has a 3/120 chance of choosing a single letter.
>>> random.seed(1)
>>> sum([1 if len(random.choice(v)) == 1 else 0 for _ in range(120)])
3
# xeger(v) has ~25% chance of choosing a single letter, because the length
and match are chosen independently.
> from rstr import xeger
> sum([1 if len(xeger('[abc]{1,4}')) == 1 else 0 for _ in range(120)])
26算法心得:高效算法的奥秘(原书第2版)
(美)Henry S. Warren, Jr. / 爱飞翔 / 机械工业出版社 / 2014-3 / 89.00
【编辑推荐】 由在IBM工作50余年的资深计算机专家撰写,Amazon全五星评价,算法领域最有影响力的著作之一 Google公司首席架构师、Jolt大奖得主Hoshua Bloch和Emacs合作创始人、C语言畅销书作者Guy Steele倾情推荐 算法的艺术和数学的智慧在本书中得到了完美体现,书中总结了大量高效、优雅和奇妙的算法,并从数学角度剖析了其背后的原理 【读者评价......一起来看看 《算法心得:高效算法的奥秘(原书第2版)》 这本书的介绍吧!
