I want to get contents of a js file comments. I tried using the code
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")
The result I get is
This is a comment.
*/
/*
This is another comment.
How can I get the comments separately ?