fork download
  1. import re
  2.  
  3. string = """123456789|XXX|1234567|05/05/2012 00:00|81900153|Signed|LASTNAME,FIRSTNAME, M.S.|024813|XXX|3410080|DNR Order Verification:Scanned|
  4.  
  5. xyz pqs 123
  6.  
  7. [report_end]
  8.  
  9. 123456789|XXX|1234567|05/05/2012 00:00|81900153|Signed|LASTNAME,FIRSTNAME, M.S.|024813|XXX|3410080|A Note|
  10.  
  11. xyz pqs 123
  12.  
  13. [report_end]"""
  14. pattern = re.compile(r"((?:.*?\|){11})\s+(.*)\s+(\[report_end\])")
  15.  
  16. for (match1, match2, match3) in re.findall(pattern, string):
  17. print match1 +"\n"+ match2 +"\n"+ match3 +"\n"
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
123456789|XXX|1234567|05/05/2012 00:00|81900153|Signed|LASTNAME,FIRSTNAME, M.S.|024813|XXX|3410080|DNR Order Verification:Scanned|
xyz pqs 123
[report_end]

123456789|XXX|1234567|05/05/2012 00:00|81900153|Signed|LASTNAME,FIRSTNAME, M.S.|024813|XXX|3410080|A Note|
xyz pqs 123
[report_end]