openBrain wrote: ↑Fri Sep 24, 2021 5:29 pm
Optimally you should tell the inner parentheses are non capturing with :
Code: Select all
print(re.search(r'<test>((? :.|\n)*?)<\/test>',test).group())
This is not worked example:
raise source.error("unknown extension ?" + char,
re.error: unknown extension ? at position 8
Ok. but how to make expression for get result without "<test>""</test>"?
i can use:
Code: Select all
print(re.search(r'<test>((.|\n)*?)<\/test>',test).group().replace("<test>","").replace("</test>","")
But maybe there is a better way?