import re text = r"""--hello --goodbye ROW_NUMBER() OVER (ORDER BY DATE) --date --comment with some indentation --another comment with some indentation""" print( re.findall(r'^[^\S\r\n]*(--.*)', text, re.M) )
Standard input is empty
['--hello', '--goodbye', '--comment with some indentation', '--another comment with some indentation']