# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\".*?(hotelscombined\.com).*?\""
test_str = "<p>We had original plans to stop in <strong>Savannah</strong> for a night, but it was so close to Charleston that we decided to just top there for a few hours for lunch and a look and then drive the other few hours to Jacksonville.</p> <p>We started fairly late in the morning as we took the kids to a playground to expend their energy first thing in the morning. After half an hour of so of playing pirates we all jumped into the car to Savannah.</p> <p>In Savannah <strong>we ate at the coolest Pirate House restaurant</strong> that was built in the 1700�s. We posted a postcard and then bounced back into our mini van for the drive to <strong>Jacksonville</strong>.</p> <p>Drive was pretty uneventful with one amazing bridge and crossing over the border into Florida was exciting too.</p> <p>We realized we�d <a title=\"Where to stay when you are road tripping East Coast USA\" href=\"/\">booked a hotel at the actual airport</a>, but it was super cheap and had nearby food so we ate, then put the kids to bed. <em><a href=\"http://www.hotelscombined.com/Hotel/Jacksonville_Airport_Hotel.htm\" target=\"_blank\">For the latest prices at the Hilton click here. </a></em></p> <p><img style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"/files/\" alt=\"DSC07623.jpg\" width=\"700\" height=\"465\" /></p> <p> </p>"
matches = re.search(regex, test_str, re.DOTALL | re.IGNORECASE)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.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