import re
regex = re.compile(r"(<p class=\"outline\"><outline><\/p>)(.*)(<p class=\"outline-end\"><outline-end><\/p>)", flags=re.DOTALL)
test_str = ("<p class=\"outline\"><outline></p>\n"
"<p class=\"list\">Chapter Outline</p>\n"
"<p class=\"txt\">General Aspects of Gingival Epithelium Biology</p>\n"
"<p class=\"list\"><list></p>\n"
"<p class=\"txt\">Development of Gingival Sulcus</p>\n"
"<p class=\"list-end\"><list-end></p>\n"
"<p class=\"txt\">Cuticular Structures on the Tooth</p>\n"
"<p class=\"list\"><list></p>\n"
"<p class=\"txt\">Gingival Fluid (Sulcular Fluid)</p>\n"
"<p class=\"txt\">Oral (Outer) Epithelium</p>\n"
"<p class=\"list-end\"><list-end></p>\n"
"<p class=\"txt\">Clinical Features</p>\n"
"<p class=\"txt\">Marginal Gingiva</p>\n"
"<p class=\"txt\">Interdental Gingiva</p>\n"
"<p class=\"txt\">Conclusion</p>\n"
"<p class=\"list-end\"><list-end></p>\n"
"<p class=\"outline-end\"><outline-end></p>\n\n"
" ")
match = regex.search(test_str)
if match:
print(f"Match was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html