I'm trying replace a block of text inside of tags with python sub.
Block of text:
text = """##startBlablaTag##
blablabla
blebleble
bliblibli
##endtBlablaTag##
Using the following regexp with "search" I can catch what's inside of the tags
>>> re.search(r'^##\w+Blabla\w+##\n(.*)##\w+Blabla\w+##', text, re.MULTILINE | re.DOTALL).group(1)
'blablabla\blebleble\bliblibli\n'
>>>
but when I try with "sub" to replace, I can't replace the whole content, just the end...
>>> re.sub(r'^##\w+Blabla\w+##\n(.*)##\w+Blabla\w+##', r'\g<1>test!', text, flags=re.MULTILINE | re.DOTALL)
'blablabla\nblebleble\nbliblibli\ntest!'
Expected:
##startBlablaTag##
test!
##endtBlablaTag##
Anybody knows how to replace the whole content inside the tags?
Thanks!