# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(\<li\>\<a target.+?\>)(.+)(\<\/a\>\<\/li\>)"
test_str = ("Функция Blue\n"
"Функция ChrW [VBA]\n"
"Функция CreateUnoDialog\n"
"Функция CurDir\n"
"Функция Дата\n"
"Функция DateSerial\n"
"Функция DateValue\n"
"Функция Day\n"
"Функция DDB [VBA]\n"
"Функция Dir\n"
"Функция Eof\n"
"Функции обработки ошибок\n"
"Функция FileAttr\n"
"Функция FileDateTime\n"
"Функция FileExists\n"
"Функция FileLen\n"
"Функция FormatDateTime [VBA]\n"
"Функция FormatNumber [VBA]\n"
"Функция FreeFile\n"
"Функция FV [VBA]\n"
"Функция GetAttr\n"
"Функция Green\n"
"Функция InStrRev [VBA]\n"
"Функция Input [VBA]\n"
"Функция InputBox\n"
"Функция IPmt [VBA]\n"
"Функция IRR [VBA]\n"
"Функция Loc\n"
"Функция Lof\n"
"Функция MIRR [VBA]\n"
"Функция Month\n"
"Функция MonthName [VBA]\n"
"Функция NPer [VBA]\n"
"Функция NPV [VBA]\n"
"Числовые функции\n"
"Функция Pmt [VBA]\n"
"Функция PPmt [VBA]\n"
"Функция PV [VBA]\n"
"Функция QBColor\n"
"Функция Rate [VBA]\n"
"Функция Red\n"
"Функция RGB\n"
"Функция RGB [VBA]\n"
"Функция Round [VBA]\n"
"Функция Seek\n"
"Функция SLN [VBA]\n"
"Функция StrConv [VBA]\n"
"Функция StrReverse [VBA]\n"
"Функция SYD [VBA]\n"
"Функция WeekDay\n"
"Функция WeekdayName [VBA]")
subst = "$2"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
if result:
print (result)
# 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