I'd like to match all patterns between <PDF>
and </PDF>
inside a string:
import re
lines = """
hello
<PDF>
bla1
</PDF>
test
<PDF>
bla2
</PDF>
"""
matches = re.findall(r"<PDF>.*</PDF>", lines, re.DOTALL)
print(matches)
Output:
['<PDF>\nbla1\n</PDF>\ntest\n<PDF>\nbla2\n</PDF>']
Expected Output:
['<PDF>\nbla1\n</PDF>', '<PDF>\nbla2\n</PDF>']
What's going wrong here? How can I ensure that no text between </PDF>
and <PDF>
gets matched?