# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = (r"c1:account id="(?<accountID>[^\"]*)"><c1:code>(?<accountCode>[^\"]*)<\/c1:code><c1:name>[^\"]*c1:provider code="(?<providerCode>[^\"]*)"\/><c1:parent id="(?<parentID>[^\"]*)"\/><\n"
r"c1:credit_score_consent.*?c1:status.*?c1:code>(?<Status>[\d])<")
test_str = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><getAccountResponse xmlns=\"http://api.csr.mind.com\"><getAccountReturn><?xml version="1.0" encoding="UTF-8"?><ns37:response xmlns:ns37="http://api.csr.mind.com/getAccount" xmlns:c3="http://api.csr.mind.com/creditCardDetails" xmlns:c1="http://api.csr.mind.com/account" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="getAccount.xsd"><c1:account id="724001"><c1:code>1499884276</c1:code><c1:name>Florin Test Limited2</c1:name><c1:type use_own_lc_functionality="true">1</c1:type><c1:class blocked_selfcare_access="false" blocked_selfcare_registration="false" default_selfcare_profile="" description="Master" group_code="MA" type="3">1000</c1:class><c1:category>0</c1:category><c1:group/><c1:provider code="EL"/><c1:parent id="0"/><\n"
"c1:credit_score_consent>false</c1:credit_score_consent><c1:credit_score last_change_date="" last_inquiry_date="" last_inquiry_score="">E</c1:credit_score><c1:product code="MPACK1" type=""/><c1:contract length="0"/><c1:web_login_name>1499884276</c1:web_login_name><c1:web_password>**************************************************************************</c1:web_password><c1:web_password_hint/><c1:tou_accepted>false</c1:tou_accepted><c1:participates_in_fub_sharing>true</c1:participates_in_fub_sharing><c1:closed_fub_sharing_group>true</c1:closed_fub_sharing_group><c1:fub_sharing_group_id>724001</c1:fub_sharing_group_id><c1:ivr_password/><c1:block_ivr>false</c1:block_ivr><c1:privacy_level>P</c1:privacy_level><c1:note/><c1:creation_date>20201012</c1:creation_date><c1:status><c1:code>1</c1:code><c1:reason description="Manual active account creation">12</c1:reason></c1:status><c1:discount>0.0</c1:discount><c1:credit_limit><c1:limited_credit_class>C</c1:limited_credit_class><c1:limited_credit_class_description>C – Spending Limit:</c1:limited_credit_class_description><c1:limited_credit_type>DEF</c1:limited_credit_type><c1:limited_credit_amount>200</c1:limited_credit_amount></c1:credit_limit><c1:tax><c1:exemptions><c1:communication><c1:federal>false</c1:federal><c1:state>false</c1:state><c1:county>false</c1:county><c1:city>false</c1:city><c1:district>false</c1:district></c1:communication><c1:tax_overrides/></c1:exemptions><c1:location><c1:geocode>700130070</c1:geocode><c1:incorporated_area>true</c1:incorporated_area></c1:location></c1:tax><c1:gl_segment code="EA6"/><c1:billing><c1:billable>true</c1:billable><c1:identification_number/><c1:cycle billing_period_from_date="20201013" billing_period_to_date="20201112" description="Monthly BC 13">13</c1:cycle><c1:split><c1:amount curr_alpha_code="CAD">0</c1:amount><c1:paid_by/></c1:split><c1:payment_terms use_provider_default="true"><c1:days_from_invoice_generation>21</c1:days_from_invoice_generation></c1:payment_terms><c1:exclude_from_overdue_handling>false</c1:exclude_from_overdue_handling><c1:dc_path_code>default_path_el</c1:dc_path_code><c1:participates_in_draft_bc>false</c1:participates_in_draft_bc></c1:billing><c1:invoice_shipment><c1:use_provider_settings/><c1:minimum_amount curr_alpha_code="CAD">-1</c1:minimum_amount><c1:ship_when_negative_amount>true</c1:ship_when_negative_amount></c1:invoice_shipment><c1:payment_settings><c1:bank><c1:code/><c1:name/><c1:branch/><c1:account><c1:number/><c1:holder/><c1:type/><c1:method_status>PENDING</c1:method_status><c1:routing_number/></c1:account></c1:bank><c3:credit_card><c3:token/><c3:code/><c3:number/><c3:expiration/><c3:holder/><c3:start_date/><c3:card_mode/></c3:credit_card><c1:general><c1:restrict_check_payments_until_date/></c1:general></c1:payment_settings><c1:notification_letters><c1:notification description="Not sufficient funds by e-mail" enabled="true" id="158"/><c1:notification description="Not sufficient funds by sms" enabled="true" id="158"/><c1:notification description="Debt Collection NL1 SMS" enabled="true" id="200"/><c1:notification description="Debt Collection NL2 SMS" enabled="true" id="201"/><c1:notification description="Debt Collection NL3 Mail" enabled="true" id="202"/><c1:notification description="Order Confirmation Notification" enabled="true" id="178"/><c1:notification description="Order Shipped Notification" enabled="true" id="179"/><c1:notification description="Enrollment in preauthorized payment program SMS" enabled="true" id="167"/><c1:notification description="Credit Card Expired SMS" enabled="true" id="173"/><c1:notification description="Credit Card Expired Mail" enabled="true" id="173"/><c1:notification description="Move from limited credit to credit SMS" enabled="true" id="177"/><c1:notification description="Number porting successful SMS" enabled="true" id="168"/><c1:notification description="Authentication PIN changed SMS" enabled="true" id="165"/><c1:notification description="Update Credit Card SMS" enabled="true" id="166"/><c1:notification description="Password Change SMS" enabled="true" id="159"/><c1:notification description="Password Change Mail" enabled="true" id="159"/><c1:notification description="Invoice generated for postpaid account Mail" enabled="true" id="28"/><c1:notification description="Debt Collection Message 2 Mail" enabled="true" id="201"/><c1:notification description="Credit Limit Removal Confirmation" enabled="true" id="177"/><c1:notification description="CC Expiration Threshold 1" enabled="true" id="25"/><c1:notification description="CC Expiration Threshold 2" enabled="true" id="26"/><c1:notification description="CC Expiration Threshold 1 Mail" enabled="true" id="25"/><c1:notification description="CC Expiration Threshold 2 Mail" enabled="true" id="26"/><c1:notification description="Limited Credit Alerts for SMS" enabled="true" id="152"><c1:parameter value="50"/><c1:parameter value="30"/><c1:parameter value="10"/></c1:notification><c1:notification description="Limited Credit Suspension SMS" enabled="true" id="80"/><c1:notification description="Document Shipment" enabled="true" id="1005"/></c1:notification_letters><c1:shipment><c1:presentation_format>ELDEFMA</c1:presentation_format><c1:ship_email>true</c1:ship_email><c1:contact>698198</c1:contact><c1:hard_copy_charge><c1:use_provider_settings/><c1:type>0</c1:type><c1:per_item curr_alpha_code="CAD">0</c1:per_item><c1:per_page curr_alpha_code="CAD">0</c1:per_page></c1:hard_copy_charge></c1:shipment><c1:advanced><c1:field code="DEVICE_PROTECTION" label="Device Protection" mandatory="false" override="true" override_in_selfcare="false" type="1">1499884276</c1:field><c1:field code="ACCT_LANGUAGE" label="Account Language" mandatory="true" override="true" override_in_selfcare="false" type="4" valid_values="English,French">English</c1:field><c1:field code="COMPLEGAL" label="Legal Name" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="BUSSALESREP" label="Business Sales Representative" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="MARKETOFFERSEMAIL" label="Market Offers Email" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="Yes,No"/><c1:field code="CHECKREQ" label="CHECKREQ" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="UPGRADE_ELIGIBLE" label="Eligible for Upgrade" mandatory="false" override="false" override_in_selfcare="false" type="4" valid_values="Yes,No"/><c1:field code="AUTHORIZEDOTHER" label="Authorized other" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="COMMACCTLINK" label="Commercial Account Link" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="INDIVIDUAL_COUPON_CODE" label="Individual coupon list" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="SALES" label="Door to Door / Outbound Sales" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="MATREP" label="M.A.T Representative" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="NEURAL_RESPONSE" label="NEURAL_RESPONSE" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="D2DOS" label="Alternative Sales ID" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="SMSCONTACTPN" label="Primary Phone number for SMS notification" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="UPGRADE_ACCEPTED" label="Accepted Upgrade" mandatory="false" override="false" override_in_selfcare="false" type="4" valid_values="Yes,No"/><c1:field code="NICKNAME" label="Nickname" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="ELIGIBLEREFUNDCHEQUE" label="Eligible for refund cheque after final invoice" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="Yes,No"/><c1:field code="HARDCOPY" label="Hard Copy" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="Y,N"/><c1:field code="PROMOTEST" label="Promo Test" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="1,2,3"/><c1:field code="CSGACCTNUMBER" label="CSG Account Number" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="COMPTRADE" label="Operating Name" mandatory="false" override="true" override_in_selfcare="false" type="1"/><c1:field code="DEBTHANDLINGSTATUS" label="Debt handling status" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="Pending collections,Sent to collections,No collections,Bankruptcy,Collection Letter"/><c1:field code="GLSEGMENTSET" label="G/L Segment updated based on 1st Service agreement" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="Y,N"/><c1:field code="CALL_REDIRECT" label="Call redirect" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="On,Off"/><c1:field code="IS_REGISTERED" label="Is registered in Self-Care" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="True,False"/><c1:field code="MARKETOFFERSCALL" label="Market Offers Call" mandatory="false" override="true" override_in_selfcare="false" type="4" valid_values="Yes,No"/></c1:advanced><c1:contact_list><c1:contact id="698198" invoice="true" primary="true"><c1:name><c1:last>Limited2</c1:last><c1:middle/><c1:first>Florin Test</c1:first><c1:company/></c1:name><c1:title/><c1:gender>0</c1:gender><c1:address_type>F</c1:address_type><c1:address><c1:line1>6080 Young St</c1:line1><c1:line2/><c1:line3/><c1:line4/><c1:line5/><c1:line6/><c1:line7/><c1:line8/><c1:line9/><c1:line10/></c1:address><c1:city>Halifax</c1:city><c1:state>Nova Scotia</c1:state><c1:zip>B3K 5M3</c1:zip><c1:country>CA</c1:country><c1:phone><c1:home/><c1:business/><c1:mobile/></c1:phone><c1:fax/><c1:email>florin.ropota@mindcti.com</c1:email><c1:email_list><c1:email address="florin.ropota@mindcti.com" main="true"/></c1:email_list><c1:birthday/><c1:contact_type>LEGAL</c1:contact_type><c1:national_ID/><c1:identity_type/><c1:identity_no/><c1:place_of_birth/><c1:nationality/><c1:father_name/><c1:mother_maiden_name/><c1:power_of_attorney/><c1:employer/><c1:employer_address/><c1:employer_phone/><c1:gen_info1 description="Nickname" visibile="true"/><c1:gen_info2 description="Second ID Type" visibile="true"/><c1:gen_info3 description="Second ID Number" visibile="true"/><c1:gen_info4 description="General contact fourth field" visibile="false"/><c1:issuing_country>CA</c1:issuing_country></c1:contact></c1:contact_list><c1:account_balance><c1:balance curr_alpha_code="CAD">-137</c1:balance><c1:remaining curr_alpha_code="CAD">-57.45</c1:remaining><c1:loyalty_points>0</c1:loyalty_points><c1:deposit curr_alpha_code="CAD">0</c1:deposit><c1:disputed_amount curr_alpha_code="CAD">0</c1:disputed_amount><c1:usage curr_alpha_code="CAD">0</c1:usage></c1:account_balance><c1:balance_threshold_alert><c1:threshold curr_alpha_code="CAD">0</c1:threshold></c1:balance_threshold_alert><c1:recurring_charges><c1:disable_automatic_rc>false</c1:disable_automatic_rc></c1:recurring_charges><c1:selfcare_profile>SELFCAREFULL</c1:selfcare_profile><c1:email>florin.ropota@mindcti.com</c1:email><c1:web_access><c1:notification_method>0</c1:notification_method><c1:phone_number/></c1:web_access><c1:user_disabled>false</c1:user_disabled><c1:selfcare_user_details><c1:user_must_change_password>false</c1:user_must_change_password><c1:password_expiration_date>19700101</c1:password_expiration_date><c1:password_never_expires>true</c1:password_never_expires><c1:user_disabled_reason>0</c1:user_disabled_reason><c1:registered>false</c1:registered></c1:selfcare_user_details><c1:nearest_billable_account id="724001"/><c1:additional_information/><c1:language>en</c1:language></c1:account></ns37:response></getAccountReturn></getAccountResponse></soapenv:Body></soapenv:Envelope>")
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