# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"([\d]{1,2})\s+([\w]+)\s+([\d]{4})\s+-\s+([\d]{1,2})\s+([\w]+)\s+([\d]{4})\s+([\d]{1,2})\s+N[a,ä]chte\s+([.\s\S]+)\s+DERTOUR"
test_str = ("Mit freundlichen Grüßen\n"
"i.A. Center Parcs Europe N.V.\n"
"Tel.: 0221-97303042\n"
"Fax: 0221-97303019\n"
"EMail: dertour@groupepvcp.com\n"
"Vertragspartner: Center Parcs Europe N.V.; Korrespondenzadresse: Kaltenbornweg 1-3, 50679 Köln\n"
"Geschäftsführer: Pascal R.L. Ferracci, Mark David Haak Wegmann\n"
"Von: ltr-staedte.fra@dertouristik.com <ltr-staedte.fra@dertouristik.com>\n"
"Gesendet: Montag, 4. Juli 2016 14:07\n"
"An: PVCP, Dertour\n"
"Betreff: ADVISING=2016/07/04, SeqNo=738, RefNo=201607042684\n"
"CPNK§\n"
"Center Parcs Nordseeküste GmbH\n"
"Attn.: Frau Schwamborn\n"
"Kaltenbornweg 1-3\n"
"D-50679 Köln\n"
"BRV10888 Center Parcs Park Nordseeküste\n"
"-- OK gebucht --\n"
"DER-REF.: 671509446-3 RES-DAT.: 04 JUL 2016\n"
"Personen: 6 Erw.\n"
"Kopie\n"
"01 X BK792\n"
"( EUR 917.60 )\n"
"08 JUL 2016 - 15 JUL 2016 7 Nächte\n"
"Bestätigt nach Anfrage\n"
"Frau MENTHE/URSULA\n"
"Herr MENTHE/CHRISTOPH\n"
"Herr MENTHE/HEIKO\n"
"Frau MENTHE/CHRISTINA\n"
"Kind MENTHE/SILJA (08)\n"
"Kind MENTHE/JANDRIK (04)\n"
"BRV10888 Center Parcs Park Nordseeküste\n"
"-- Bitte stornieren --\n"
"DER-REF.: 671509446-2 RES-DAT.: 29 JUN 2016\n"
"Personen: 6 Erw.\n"
"Kopie: kein komplettes Storno - nur Umbuchung auf Termin 08.-15.07.\n"
"01 X BK792\n"
"( EUR 1,359.20 )\n"
"08 JUL 2016 - 18 JUL 2016 10 Nächte\n"
"Freesale\n"
"Frau MENTHE/URSULA\n"
"Herr MENTHE/CHRISTOPH\n"
"Herr MENTHE/HEIKO\n"
"Frau MENTHE/CHRISTINA\n"
"Kind MENTHE/SILJA (08)\n"
"Kind MENTHE/JANDRIK (04)\n"
"DERTOUR GmbH & Co. KG\n"
"Erlebnisparks FAX: 069/9588-5122\n"
"++ ENDE AVIS ++")
matches = re.finditer(regex, test_str, re.IGNORECASE)
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