# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r".+\/+(\d+).+?psd"
test_str = ("!Gotovoe Anya/а шарик летит/700.psd\n"
"!Gotovoe Anya/С 5 до 7. Время любовников (Сурдоперевод)/4478751.psd\n"
"!Gotovoe Anya/#вмаскешоу/8115515.psd\n"
"!Gotovoe Anya/#Гуднайтшоу/3627751.psd\n"
"!Gotovoe Anya/#Гуднайтшоу/3627751_RU.psd\n"
"!Gotovoe Anya/#ЛавСтайл/3086771-lavstayl.psd\n"
"!Gotovoe Anya/#яздесь/4572015.psd\n"
"!Gotovoe Anya/#ЯЗДЕСЬ/6925565.psd\n"
"!Gotovoe Anya/(Не)идеальная женщина/10010315.psd\n"
"!Gotovoe Anya/... а шарик летит/700.psd\n"
"!Gotovoe Anya/@Жених/5851405.psd\n"
"!Gotovoe Anya/«V» значит Вендетта/2457401.psd\n"
"!Gotovoe Anya/«Весёлые» каникулы/1341041.psd\n"
"!Gotovoe Anya/«Вне игры. Пролог». Документальный фильм/4460771.psd\n"
"!Gotovoe Anya/«Кедр» пронзает небо/1193411.psd\n"
"!Gotovoe Anya/«Мерседес» уходит от погони/15380.psd\n"
"!Gotovoe Anya/«Посейдон» спешит на помощь/1684351.psd\n"
"!Gotovoe Anya/«Старый» Новый год/2454371-staryy-novyy-god.psd\n"
"!Gotovoe Anya/«Сто грамм» для храбрости/1363311.psd\n"
"!Gotovoe Anya/«Тигры» на льду/2312_RU.psd\n"
"!Gotovoe Anya/0 в пользу Танечки/2391.psd\n"
"!Gotovoe Anya/1/2930981.psd\n"
"!Gotovoe Anya/1+1 (Сурдоперевод)/2681801.psd\n"
"!Gotovoe Anya/1+1 дома 8 марта/2474581.psd\n"
"!Gotovoe Anya/1+1 дома 8 марта/2474581-1-1-doma-8-marta-2.psd\n"
"!Gotovoe Anya/1+1/2214021.psd\n"
"!Gotovoe Anya/2 Brothers On The 4Th Floor - караоке/10307755.psd\n"
"!Gotovoe Anya/2 дня/95161.psd")
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