# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"((<.*?):Envelope.*Envelope>)"
test_str = ("31-10-2014 00:12:12,075 [INFO] REQUEST:\n"
"<?xml version=\"1.0\" encoding=\"utf-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:ns2=\"urn:ZEKTransactionService\" xmlns:ns1=\"http://zeksoap.xml.prechku.sys:7001/dvzek/services/ZEKTransactionService\" xmlns:ns3=\"http://impl.zkb.appl.ch\"><SOAP-ENV:Body SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><ns1:closeLeasingMietvertrag><identityDescriptor xsi:type=\"ns2:IdentityDescriptor\"><clientUserId xsi:type=\"xsd:string\">EXPLOIT</clientUserId><name xsi:type=\"xsd:string\">RCISoapUser</name><password xsi:type=\"xsd:string\">ziucx+okpb</password></identityDescriptor><requestEntities xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"ns2:RequestEntity[1]\"><item xsi:type=\"ns2:RequestEntity\"><addressDescription xsi:type=\"ns2:AddressDescription\"><birthdate xsi:type=\"xsd:string\">1961-03-13</birthdate><city xsi:type=\"xsd:string\">Balsthal</city><country xsi:type=\"xsd:string\">CHE</country><datumWohnhaftSeit xsi:type=\"xsd:string\">1990-04-01</datumWohnhaftSeit><firstname xsi:type=\"xsd:string\">Mina</firstname><housenumber xsi:type=\"xsd:string\">.</housenumber><legalForm xsi:type=\"xsd:int\">1</legalForm><name xsi:type=\"xsd:string\">Bilalli</name><nationality xsi:type=\"xsd:string\">XKO</nationality><sex xsi:type=\"xsd:int\">1</sex><street xsi:type=\"xsd:string\">Guntenfluhweg 14</street><zip xsi:type=\"xsd:string\">4710</zip><zivilstandscode xsi:type=\"xsd:int\">1</zivilstandscode></addressDescription><debtorRole xsi:type=\"xsd:int\">0</debtorRole><forceNewAddress xsi:type=\"xsd:int\">0</forceNewAddress><previousReturnCode xsi:type=\"xsd:int\">0</previousReturnCode><refno xsi:type=\"xsd:int\">1</refno></item></requestEntities><leasingMietvertrag xsi:type=\"ns2:LeasingMietvertragDescription\"><anzahlMonatlicheRaten xsi:type=\"xsd:int\">0</anzahlMonatlicheRaten><anzahlung xsi:type=\"xsd:int\">0</anzahlung><bonitaetsCodeIKO xsi:type=\"xsd:int\">4</bonitaetsCodeIKO><bonitaetsCodeZEK xsi:type=\"xsd:int\">5</bonitaetsCodeZEK><datumBonitaetIKO xsi:type=\"xsd:string\">2014-10-30</datumBonitaetIKO><datumBonitaetZEK xsi:type=\"xsd:string\">2014-10-30</datumBonitaetZEK><debtorRole xsi:type=\"xsd:int\">0</debtorRole><ersteGrosseRate xsi:type=\"xsd:int\">0</ersteGrosseRate><filiale xsi:type=\"xsd:int\">0</filiale><grosseSchlussrate xsi:type=\"xsd:int\">0</grosseSchlussrate><herkunft xsi:type=\"xsd:int\">0</herkunft><kennzeichen xsi:type=\"xsd:int\">0</kennzeichen><kreditBetrag xsi:type=\"xsd:float\">0</kreditBetrag><kreditVertragID xsi:type=\"xsd:string\">142051011553</kreditVertragID><monatsrate xsi:type=\"xsd:float\">0</monatsrate><restwert xsi:type=\"xsd:int\">0</restwert><sicherstellungsCode xsi:type=\"xsd:int\">0</sicherstellungsCode><theoRestSaldo xsi:type=\"xsd:float\">0</theoRestSaldo><vertragsStatus xsi:type=\"xsd:int\">0</vertragsStatus></leasingMietvertrag></ns1:closeLeasingMietvertrag></SOAP-ENV:Body></SOAP-ENV:Envelope>\n"
" | Thread:http-7001-Processor23")
matches = re.search(regex, test_str, re.IGNORECASE | re.MULTILINE | re.DOTALL)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.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