# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\b(\d{1,3}(?: \d{3})+)(,\d{2})? {,2}[а-яА-Я,. ()]+\b(без|\d{2} копеек\)?, без)"
test_str = ("3 322 559,32 руб. без НДС.\n"
" 598 060,67 руб. НДС \n"
"3 920 619,99руб. с НДС.\n\n"
"5 026 813,65 руб. без НДС;\n"
" 904 826,46 руб. НДС (18%);\n"
"5 931 640,11 руб. с НДС\n\n"
"Лот 1.\n"
"4 837 251,02 руб. без НДС;\n"
"870 050,18 руб. НДС (18%);\n"
"5 707 956,20 руб. с НДС\n\n"
"Лот 2.\n"
"75 290,87 руб. без НДС;\n"
"13 552,36 руб. НДС (18%);\n"
"88 843,23 руб. с НДС\n\n"
"ИТОГО:\n"
"4 912 541,89 руб. без НДС\n"
"884 257,54 руб. НДС (18%);\n"
"5 796 799,43 руб. с НДС\n\n"
"1 307 856 (Один миллион триста семь тысяч восемьсот пятьдесят шесть) рублей 67 копеек, в т.ч. НДС.\n"
"1 214 490 (Один миллион двести четырнадцать тысяч четыреста девяносто) рублей 67 копеек, без учета НДС.\n\n"
"307 272,00 рублей (Триста семь тысяч двести семьдесят два рубля 00 копеек), включая НДС. \n"
"260 400,00 рублей (Двести шестьдесят тысяч четыреста рублей 00 копеек), без учета НДС.\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