Jul-10-2020, 11:13 AM
Hi
I have re code with find findall() function. I understand that findall supposed to find a certain match in the given string, but the output that I'm getting suggest something else, I'm getting everything else except what I'm searching.
Can anybody explain to me what's happening here?
I have a xml file with this data
I have re code with find findall() function. I understand that findall supposed to find a certain match in the given string, but the output that I'm getting suggest something else, I'm getting everything else except what I'm searching.
Can anybody explain to me what's happening here?
I have a xml file with this data
<?xml version="1.0" encoding="UTF-8"?> From: [email protected] Sent: 22 November 11:10 AM To: [email protected] Good day, Claim number: 1234567 Policy number: 2468 EA Ref number: 19-24567-R-01 Client details: Client One She was rude Kind regards Person <?xml version="1.0">this is the code:
import re with open('test_file.xml', 'rb') as f: file_content = f.read() decoded = file_content.decode('iso-8859-1') found = re.findall(r'encoding="UTF-8"\?>(.*?)^<\?xml version="1.0"', decoded, re.M | re.S) print(found)Output, It looks like the code cleaned the text: Can someone please explain this code for, why do we getthis with findall function
Output:['\nFrom: [email protected]\nSent: 22 November 11:10 AM\nTo: [email protected]\nGood day,\nClaim number: 1234567\nPolicy number: 2468\nEA Ref number: 19-24567-R-01\n\nClient details: Client One\n\nShe was rude\nKind regards\n\nPerson\n']