# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(^(\S+):(.*)$)|(^.*$)"
test_str = ("Yanitic:ачив не найдено\n\n"
"yurahm: медаль золото(23:10 12-12-2014)\n"
"59д Жертвам Голодомору(T2617, Voronovytsya, Chernivets' ka oblast, Ukraine) https://www.ingress.com/intel?ll=48.530544,26.64706&z=17&pll=48.530544,26.64706\n"
"59д Памятник Неизвестного Солдату (Unnamed Road, Sokil, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=48.529953,26.645298&z=17&pll=48.529953,26.645298\n"
"58д Капличка(Unnamed Road, Ruda, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=48.555892,26.567197&z=17&pll=48.555892,26.567197\n"
"39д Олень(E50, Vinnyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.366811,27.984859&z=17&pll=49.366811,27.984859\n"
"39д Сержант Петренко(E50, Vinnyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.366651,27.985773&z=17&pll=49.366651,27.985773\n"
"32д Собор Святого Михаїла(Olimpiiska St, Khmelnytskyi, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.435902,26.958889&z=17&pll=49.435902,26.958889\n"
"15д Стадиончик(Lyali Ratushnoi Street, 128, Vinnytsia, Vinnyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.221695,28.433667&z=17&pll=49.221695,28.433667\n\n"
"zZHunteRZz:ачив не найдено\n\n"
"zZWehrZz:ачив не найдено\n"
"GhostPathfinder: медаль золото(03:19 19-02-2016)\n"
"54д памятник Володарскому(Н03, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.806018,27.56081&z=17&pll=49.806018,27.56081\n"
"54д церковь(Н03, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.806456,27.561546&z=17&pll=49.806456,27.561546\n"
"54д Павшим В Боях(Н03, Krasnoselka, Zhytomyrs' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.989098,28.000007&z=17&pll=49.989098,28.000007\n"
"54д Часовня на перекрёстке(E101, Chernihivs' ka oblast, Ukraine) https://www.ingress.com/intel?ll=51.139195,31.862377&z=17&pll=51.139195,31.862377\n"
"54д Прокопович Петр Иванович(E101, Chernihivs' ka oblast, Ukraine) https://www.ingress.com/intel?ll=51.298025,32.770144&z=17&pll=51.298025,32.770144\n\n"
"1д Filarmoniya(Haharina street, 5, Khmelnytskyi, Khmel' nyts' ka oblast, Ukraine) https://www.ingress.com/intel?ll=49.418876,26.976199&z=17&pll=49.418876,26.976199")
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