So I have this piece of code which I made with the help of other stackoverflow answers and I really have no idea why it is not working.I want to replace SOMETHING with NOTHING and delete a line with spaces and 50 in it.
#Expected output:
"""NOTHING
1 1
2345234
abcdefg
foobar
wrwerdfdsf"""
import re
s="""SOMETHING
1 1
2345234
abcdefg
foobar
50
wrwerdfdsf"""
repl = {'SOMETHING':'NOTHING',' 50n':''}
n=re.sub(r'^(SOMETHING)n.*n.*n.*n.*n.*n.*n.*n( 50n)',lambda x : repl[x.group()] if x.group() in repl else x.group(),s,flags=re.M)
It replaces nothing. Maybe I need to write something in these brackets of x.group()?