def strip_powershell_comments(data):
"""
Strip block comments, line comments and empty lines from a PowerShell source file.
"""
# strip block comments
strippedCode = re.sub(re.compile('<#.*?#>', re.DOTALL), '', data)
# strip blank lines and lines starting with #
# noinspection PyPep8
strippedCode = "\n".join([line for line in strippedCode.split('\n') if ((line.strip() != '') and
(not line.strip().startswith("#")))])
# TODO: strip comments at the end of lines
return strippedCode
评论列表
文章目录