RosettaCodeData/Task/Strip-comments-from-a-string/Python/strip-comments-from-a-string-3.py
2015-11-18 06:14:39 +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)