【发布时间】:2011-04-04 15:50:56
【问题描述】:
whitespace_pattern = u"\s" # bug: tried to use unicode \u0020, broke regex
time_sig_pattern = \
"""^%(ws)s*time signature:%(ws)s*(?P<top>\d+)%(ws)s*\/%(ws)s*(?P<bottom>\d+)%(ws)s*$""" %{"ws": whitespace_pattern}
time_sig = compile(time_sig_pattern, U|M)
由于某种原因,添加 Verbose 标志 X 来编译会破坏模式。
另外,我想使用 unicode 进行 whitespace_pattern 识别(假设我们会得到使用非 unicode 空格的模式,我们需要明确地检查那个 unicode 字符是否为有效空格),但模式不断中断。
【问题讨论】: