本文整理汇总了Python中sre_parse.expand_template函数的典型用法代码示例。如果您正苦于以下问题:Python expand_template函数的具体用法?Python expand_template怎么用?Python expand_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expand_template函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _expand
def _expand(self, m, template):
# XXX This code depends on internals of the regular expression
# engine! There's no standard API to do a substitution when you
# have already found the match. One should be added.
# The solution here is designed to be backwards compatible
# with previous Python versions, e.g. 1.5.2.
# XXX This dynamic test should be done only once.
if getattr(re, "engine", "pre") == "pre":
return re.pcre_expand(m, template)
else: # sre
# XXX This import should be avoidable...
import sre_parse
# XXX This parses the template over and over...
ptemplate = sre_parse.parse_template(template, m.re)
return sre_parse.expand_template(ptemplate, m)
开发者ID:alexei-matveev,项目名称:ccp1gui,代码行数:15,代码来源:ReplaceDialog.py
示例2: expand_sub
def expand_sub(string, template, debug=0, mode='all') :
""" Given a regular expression and a replacement string, generate expansions of
the regular expression and for each one return it and its transformation
as applied by the replacement string.
string : regular expression to expand
template : transformation to apply to each regular expression
mode : can take 3 values
all : return all possible shortest strings that the regular expression
would match
first : return the first string that all would return
random : return one random string that the regular expression would match
"""
pattern = sre_parse.parse(string, flags=sre_parse.SRE_FLAG_VERBOSE)
pattern.mode = mode
template = sre_parse.parse_template(template, pattern)
if debug :
print pattern
print template
for s in _iterate(pattern, pattern.data, MatchObj(pattern, "")) :
s.patient = 0
yield (s.string, sre_parse.expand_template(template, s))
开发者ID:HughP,项目名称:Palaso-Python,代码行数:22,代码来源:reggen.py
示例3: filter
def filter(match, template=template):
return sre_parse.expand_template(template, match)
开发者ID:1018365842,项目名称:FreeIMU,代码行数:2,代码来源:re.py
示例4: _expand
def _expand(pattern, match, template):
# internal: match.expand implementation hook
template = sre_parse.parse_template(template, pattern)
return sre_parse.expand_template(template, match)
开发者ID:1018365842,项目名称:FreeIMU,代码行数:4,代码来源:re.py
示例5: expand
def expand(self, template) :
template = sre_parse.parse_template(template, self.pattern)
return sre_parse.expand_template(template, self)
开发者ID:HughP,项目名称:Palaso-Python,代码行数:3,代码来源:reggen.py
示例6: filter
def filter(match, template = template): #@ReservedAssignment
return sre_parse.expand_template(template, match)
开发者ID:jda808,项目名称:mlostekk-live,代码行数:2,代码来源:re.py
示例7:
开发者ID:mcyril,项目名称:ravel-ftn,代码行数:1,代码来源:sre.py
示例8:
开发者ID:mcyril,项目名称:ravel-ftn,代码行数:1,代码来源:ReplaceDialog.py
注:本文中的sre_parse.expand_template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论