html6="""
<p<ins style="background:#e6ffe6;">re><code</ins>>
int aint bint c<ins style="background:#e6ffe6;"></code></ins></p<ins style="background:#e6ffe6;">re</ins>><p>int d</p>
"""
Html6和Html7是一样的,只是Html7有“\n”
^{pr2}$html6和html7都不匹配?,但如果我将“\n”替换为“”,则两者都将非常相似。在
print re.match(p_to_pre_code_pattern,html6.replace("\n",""))
print re.match(p_to_pre_code_pattern,html7.replace("\n",""))
我想知道在不调用replace("\n",""))
的情况下,如何更改将同时匹配html6和html7的p_to_pre_code_pattern
?在
可能您在调用
re.DOTALL
时错过了re.compile(..., re.VERBOSE|re.DOTALL)
标志相关问题 更多 >
编程相关推荐