fork download
  1. import re
  2.  
  3. data = 'Date : 2020-09-06 20:43:00Ack No : 3320000266Original for RecipientInvoice No.: IN05200125634Date of Issue: 06.09.2015TAX INVOICE(Issued u/s 31(1) of GST Act, 2017)POLO INDUSTRIES LIMITEDCIN: K253648B85PLC015063GSTIN: 3451256132uuy668803E1Z9PAN: BBB7653279K .....'
  4.  
  5. regex_ack_no = re.compile(r"Ack No\s*:\s*(\d+)")
  6. regex_due_date = re.compile(r"Date of Issue\s*:\s*(\d\d\.\d\d\.\d{4})")
  7. regex_CIN = re.compile(r"CIN:\s*(\w+?)GSTIN:")
  8.  
  9. ack_no = re.search(regex_ack_no, data)
  10. if ack_no:
  11. ack_no = ack_no.group(1)
  12. else:
  13. ack_no = 'Ack No not found'
  14. due_date = re.search(regex_due_date, data)
  15. if due_date:
  16. due_date = due_date.group(1)
  17. else:
  18. due_date = 'Due date not found'
  19. cin = re.search(regex_CIN, data)
  20. if cin:
  21. cin = cin.group(1)
  22. else:
  23. cin = 'CIN not found'
  24.  
  25. print([ack_no, due_date, cin])
Success #stdin #stdout 0.02s 9708KB
stdin
Standard input is empty
stdout
['3320000266', '06.09.2015', 'K253648B85PLC015063']