# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"([^\?]*)AUD (\d*)"
test_str = ("The following fees and deposits are charged by the property at time of service, check-in, or check-out.\n\n"
"Breakfast fee: between AUD 9.95 and AUD 20.00 per person (approximately)\n"
"Fee for in-room wireless Internet: AUD 0.00 per night (rates may vary)\n"
"Fee for in-room high-speed Internet (wired): AUD 9.95 per night (rates may vary)\n"
"Fee for high-speed Internet (wired) in public areas: AUD 9.95 per night (rates may vary)\n"
"Late check-out fee: AUD 40\n"
"Rollaway beds are available for an additional fee\n"
"Onsite credit card charges are subject to a surcharge\n"
"The above list may not be comprehensive. Fees and deposits may not include tax and are subject to change.")
matches = re.search(regex, test_str)
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