RosettaCodeData/Task/Strip-comments-from-a-string/Python/strip-comments-from-a-string-2.py
2018-06-22 20:57:24 +00:00

5 lines
115 B
Python

import re
m = re.match(r'^([^#]*)#(.*)$', line)
if m: # The line contains a hash / comment
line = m.group(1)