我想获取一个js文件的评论内容。我尝试使用代码
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.
如何单独获取评论?
请您参考如下方法:
