RosettaCodeData/Task/Strip-comments-from-a-string/Python/strip-comments-from-a-string-2.py
2023-07-01 13:44:08 -04: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)