def remove_comments(string):
 pattern = '(\\".*?\\"|\\\'.*?\\\')|(<#.*?#>|#[^\\r\\n]*$)'
 regex = re.compile(pattern, (re.MULTILINE | re.DOTALL))
 def _replacer(match):
  if (match.group(2) is not None):
   return ''
  else:
   return match.group(1)
 return regex.sub(_replacer, string)

def remove_comments ( string ) : pattern = '(\\".*?\\"|\\\'.*?\\\')|(<#.*?#>|#[^\\r\\n]*$)' regex = re . compile ( pattern , ( re . MULTILINE | re . DOTALL ) ) def _replacer ( match ) : if ( match . group ( 2 ) is not None ) : return '' else : return match . group ( 1 ) return regex . sub ( _replacer , string )
remove comments in powershell script .