【发布时间】:2012-10-20 03:21:51
【问题描述】:
我想获取一个js文件cmets的内容。我尝试使用代码
import re
code = """
/*
This is a comment.
*/
/*
This is another comment.
*/
"""
reg = re.compile("/\*(?P<contents>.*)\*/", re.DOTALL)
matches = reg.search(code)
if matches:
print matches.group("contents")
我得到的结果是
This is a comment.
*/
/*
This is another comment.
如何分别获得 cmets ?
【问题讨论】:
标签: javascript python regex comments