-1
正则表达式从以下问题 How to automatically remove certain preprocessors directives and comments from a C header-file?字符串,在Python
header = "" #some string
p_macro = re.compile("#if.*?#endif", re.MULTILINE + re.DOTALL)
p_comment = re.compile("/\*.*?\*/", re.MULTILINE + re.DOTALL)
# Example ...
# print re.sub(p_macro, '', header)
# print re.sub(p_comment, '', header)
然而,这导致无法像
#endif // #if 0
什么能在重新表达被添加到避免这种情况?
这就是正则表达式不解析的原因。 – 2011-03-23 09:24:46
新名称?多么傲慢 – 2011-03-23 14:45:58