# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\b\W*<hr>\W*<p>(?:<a href(?:[^<]|<[^/]|</[^a]|</a[^>])*</a>\W*){2,}</p>.?$"
test_str = ("▼ Can't change language on Google Account ✓ ✓ (1) ×1 4 hours ago by user905392\n\n"
"<p>The Google Accounts home page, \"My Account\", is available in all languages offered by Google. You can change the display language suit your preferences. To do your research in the language of your choice, you can configure Google: Go to the home page, click on the nut on the right side of the screen, then go to search parameters</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://getappvalley.com/\" rel=\"nofollow noreferrer\">Appvalley</a> <a href=\"https://tutuapp.win/\" rel=\"nofollow noreferrer\">Tutuapp</a> <a href=\"https://tweakbox.mobi/\" rel=\"nofollow noreferrer\">Tweakbox</a> </p>\n\n"
"Potentially bad keyword in answer\n"
"▼ How do I fill out Google applications when their own reCAPTCHA is broken? ✓ ✓ ✓ ✓ ✓ (151) 2 days ago by user905392\n\n"
"<p>some have the same troubles as you. If you ever have the solution could you send it thanks.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://dltutuapp.com/\" rel=\"nofollow noreferrer\">Tutuapp</a> <a href=\"https://kodi.software/\" rel=\"nofollow noreferrer\">Kodi</a> <a href=\"https://luckypatcher.pro/\" rel=\"nofollow noreferrer\">Lucky Patcher</a></p>\n\n"
"Blacklisted website in answer, Link at end of answer\n"
"▼ Can't change language on Google Account ✓ ✓ (91) 2 days ago by jowell\n\n"
"<p>The Google Accounts home page, \"My Account\", is available in all languages offered by Google. You can change the display language suit your preferences.\n"
"To do your research in the language of your choice, you can configure Google:\n"
"Go to the home page, click on the nut on the right side of the screen, then go to search parameters \n\n"
"<hr>\n\n"
"<p><a href=\"https://dltutuapp.com/\" rel=\"nofollow noreferrer\">https://dltutuapp.com/</a> \n"
"<a href=\"https://kodi.software/\" rel=\"nofollow noreferrer\">https://kodi.software/</a> \n"
"<a href=\"https://luckypatcher.pro/\" rel=\"nofollow noreferrer\">https://luckypatcher.pro/</a></p>\n\n"
"Blacklisted website in answer\n"
"▼ Joycons buzzing in Portal Knights on Nintendo Switch ✓ ✓ (152) ×1 23 days ago by seth\n\n"
"<p>I want to buy it because I thought the combat system will be good.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://dltutuapp.com/\" rel=\"nofollow noreferrer\">https://dltutuapp.com/</a>\n"
" <a href=\"https://kodi.software/\" rel=\"nofollow noreferrer\">https://kodi.software/</a>\n"
" <a href=\"https://luckypatcher.pro/\" rel=\"nofollow noreferrer\">https://luckypatcher.pro/</a></p>\n\n"
"Blacklisted website in answer, Link at end of answer, Potentially bad keyword in answer\n"
"▼ How can I block ringing of incoming calls of unknown numbers? ✓ ✓ (152) a month ago by user905392\n\n"
"<p>I think that with your trick the unknown numbers can't call and they not appears on the call log</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://dltutuapp.com/\" rel=\"nofollow noreferrer\">Tutuapp</a> <a href=\"https://kodi.software/\" rel=\"nofollow noreferrer\">kodi</a> <a href=\"https://luckypatcher.pro/\" rel=\"nofollow noreferrer\">Lucky Patcher</a></p>\n\n"
"Blacklisted website in answer, Link at end of answer, Potentially bad keyword in answer\n"
"▼ My downloads keep freezing, what should I do? ✓ ✓ ✓ ✓ (1) a month ago by seth\n\n"
"<p>I too have the same problem, when I launch the app, a message appears \"a problem occurred when connecting to google servers, please try again later. I do not know what to do.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://getappvalley.com/\" rel=\"nofollow noreferrer\">https://getappvalley.com/</a>\n"
" <a href=\"https://tutuapp.win/\" rel=\"nofollow noreferrer\">https://tutuapp.win/</a>\n"
" <a href=\"https://tweakbox.mobi/\" rel=\"nofollow noreferrer\">https://tweakbox.mobi/</a></p>\n\n"
"Potentially bad keyword in answer\n"
"▼ How can Outlook automatically unsubscribe me from emails? ✓ ✓ ✓ (67) 2 months ago by avensis david\n\n"
"<p>To unsubscribe from unwanted emails from some senders there are 2 options</p>\n\n"
"<ol>\n"
"<li>The first option allows you to unsubscribe from a company's future newsletters</li>\n"
"</ol>\n\n"
"<p>Click on the 'Cancel subscription' button at the bottom of the page\n"
"Click on 'Cancel subscription'.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://getappvalley.com/\" rel=\"nofollow noreferrer\">Appvalley</a> <a href=\"https://tutuapp.win/\" rel=\"nofollow noreferrer\">Tutuapp</a> <a href=\"https://tweakbox.mobi/\" rel=\"nofollow noreferrer\">Tweakbox</a></p>\n\n"
"Blacklisted user\n"
"▼ How to style window borders in Linux Mint w/ Cinnamon? ✓ ✓ (158) 2 months ago by avensis david\n\n"
"<p>The customization under Cinnamon is very simple. Here is how to change the appearance of windows, the addition of new icons or even pointers.\n"
"The principle must be a priori the same regardless of the graphical environment.\n\n"
"→ We click on usr (like user), share and finally themes.\n"
"→ From the download folder, copy the file and paste it into the themes folder.\n"
"Picture\n"
"→ With the right click of the mouse on the freshly copied file, it is extracted here.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://plex.software/\" rel=\"nofollow noreferrer\">Plex</a> <a href=\"https://kodi.software/\" rel=\"nofollow noreferrer\">Kodi</a> <a href=\"https://luckypatcher.pro/\" rel=\"nofollow noreferrer\">Lucky Patcher</a> </p>\n\n"
"Blacklisted website in answer, Blacklisted user\n"
"▼ How can I change the public IP address? ✓ 💩 (61) ×1 2 months ago by ismart\n\n"
"<p>Change your IP address: is it legal?</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://showbox.software/\" rel=\"nofollow noreferrer\">https://showbox.software/</a>\n"
" <a href=\"https://kodi.software/\" rel=\"nofollow noreferrer\">https://kodi.software/</a>\n"
" <a href=\"https://luckypatcher.pro/\" rel=\"nofollow noreferrer\">https://luckypatcher.pro/</a></p>\n\n"
"Link at end of answer, Potentially bad keyword in answer\n"
"▼ How to style window borders in Linux Mint w/ Cinnamon? ✓ ✓ (1) ×4 2 months ago by avensis david\n\n\n"
"<p>The customization under Cinnamon is very simple. Here is how to change the appearance of windows, the addition of new icons or even pointers.\n"
"→ We click on usr (like user), share and finally themes.\n"
"→ From the download folder, copy the file and paste it into the themes folder.\n"
"Picture\n"
"→ With the right click of the mouse on the freshly copied file, it is extracted here.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://showbox.software/\" rel=\"nofollow noreferrer\">https://showbox.software/</a> \n"
"<a href=\"https://kodi.software/\" rel=\"nofollow noreferrer\">https://kodi.software/</a>\n"
" <a href=\"https://luckypatcher.pro/\" rel=\"nofollow noreferrer\">https://luckypatcher.pro/</a></p>\n\n"
"Potentially bad keyword in answer\n"
"▼ MongoDB: Replica Set - master vs. slave ✓ ✓ ✓ (60) 5 months ago by user182115\n\n"
"<p>At startup, the databases will negotiate which is master and which is slave. Upon an outage of one database server, the other will automatically take over and become master from that point on.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://kodi.software/\" rel=\"nofollow noreferrer\">Kodi</a> <a href=\"https://luckypatcher.pro/\" rel=\"nofollow noreferrer\">Lucky Patcher</a></p>\n\n"
"Link at end of answer\n"
"▼ Woocommerce Attribute kept loading in adminpanel ✓ ✓ ✓ ✓ (110) 9 months ago by JustOutblog\n\n"
"<p>I had the same problem, it was solved after updating all plugins , i did not disable any plugin.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"http://www.justoutblog.com\" rel=\"nofollow noreferrer\">JustOutblog</a> |\n"
"<a href=\"http://www.shopnship.co\" rel=\"nofollow noreferrer\">Shopnship.co</a></p>\n\n"
"Link at end of answer, Username similar to website in answer\n"
"▼ Can't start apache in XAMPP ✓ ✓ (139) a year ago by hajir.roshani\n\n"
"<p>just disable skype and vmware</p>\n\n"
"<hr>\n\n"
"<p><a href=\"http://controlmakers.ir/en/\" rel=\"nofollow noreferrer\">Controlmakers</a>\n"
"<a href=\"http://infu.ir/\" rel=\"nofollow noreferrer\">Infu</a></p>\n\n"
"Link at end of answer, Pattern-matching website in answer\n"
"▼ Android: How to distinguish CLEAR all events from notification bar from user action ✗ ✓ (94) 2 years ago by ChungCB126\n\n"
"<p>If your code is navigating the user back to the app when the notification is cleared, then you already have a problem with your design. If the user clears your notification you should NOT be trying to navigate them back. Hence the setDeleteIntent() should NOT be associated with starting any activity.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://www.dktmedia.vn\" rel=\"nofollow\"> Qu?ng cáo tr?c tuy?n</a>| <a href=\"https://www.dktmedia.vn/quang-cao-facebook.html\" rel=\"nofollow\"> Qu?ng cáo Facebook</a></p>\n\n"
"Manually reported answer\n"
"▼ Getting Window function to assign variable locally ✓ ✓ (77) 2 years ago by ChungCB126\n\n"
"<p>I have the same problem. Who can answer the question?!?</p>\n\n"
"<hr>\n\n"
"<p><a href=\"https://www.dktmedia.vn\" rel=\"nofollow\"> Qu?ng cáo tr?c tuy?n</a> | <a href=\"https://www.dktmedia.vn/quang-cao-google.html\" rel=\"nofollow\"> Qu?ng cáo Google</a></p>\n\n"
"Non-english link in answer\n"
"▼ Form get to pretty link ✓ ✓ (94) 2 years ago by Sandangku OnlineShop\n\n"
"<p>You can change it.\n"
"and you can find .htaccess.\n"
"I will ask again to my friend.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"http://www.sandangku.com/\" rel=\"nofollow\">Kaos Murah</a> <a href=\"http://www.sandangku.com/\" rel=\"nofollow\">Kaos Distro</a></p>\n\n"
"Manually reported answer\n"
"▼ print unique numbers from a sorted list python ✓ ✓ (127) 2 years ago by Sandangku OnlineShop\n\n"
"<p>Maybe I will can try it.\n"
"And the result of progress i will be coment there.\n"
"Wait me. Thank you.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"http://www.sandangku.com/\" rel=\"nofollow\">Kaos Murah</a> <a href=\"http://www.sandangku.com/\" rel=\"nofollow\">Desain Kaos</a></p>\n\n"
"Link at end of answer, Blacklisted user\n"
"▼ Form get to pretty link ✓ ✓ (60) 2 years ago by Sandangku OnlineShop\n\n"
"<p>You can change it.\n"
"and you can find .htaccess.\n"
"I will ask again to my friend.</p>\n\n"
"<hr>\n\n"
"<p><a href=\"http://www.sandangku.com/\" rel=\"nofollow\">Kaos Murah</a> <a href=\"http://www.sandangku.com/\" rel=\"nofollow\">Kaos Distro</a></p>\n\n"
"Link at end of answer\n")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
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