How do I remove lines starting with roman numbers in this multi line string:
I. LIFE.
I.
SUCCESS.
Success is counted sweetest By those who ne'er succeed. To comprehend a nec...
Want help with python code, have tried below but now working:
for line in xtemp.split('\n'): import re if line.strip("\n") != r"\b(?=[MDCLXVIΙ])M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})([IΙ]X|[IΙ]V|V?[IΙ]{0,3})\b.?" print(line)
CodePudding user response:
We can try using re.sub
here in multiline mode:
inp = """
I. LIFE.
I.
SUCCESS."""
output = re.sub(r'^[IVXLCDM] \..*\s*', '', inp, flags=re.M)
print(output) # SUCCESS.