fork download
  1. # coding=utf8
  2. # the above tag defines encoding for this document and is for Python 2.x compatibility
  3.  
  4. import re
  5.  
  6. regex = r"^.*\d*\.\d+\t\d*\.\d+.*$"
  7.  
  8. test_str = ("some information: bla bla\n"
  9. "test time: 1.34\n"
  10. "something else 23.00\n"
  11. "data1 data2\n"
  12. "0.01 0.22\n"
  13. "0.2 0.34\n"
  14. "0.2 0.34\n"
  15. "adf asdf 0.2 asdfasf 1.2 2.3 sdfs\n"
  16. ".....\n\n"
  17. "The text information before data1 can vary in number of rows and data1 and data2 can also vary.\n"
  18. "I wold prefer a solution with pandas, but everything else is acceptable.")
  19.  
  20. matches = re.finditer(regex, test_str, re.MULTILINE)
  21.  
  22. for match in matches:
  23. print(match.group(0))
  24.  
Success #stdin #stdout 0s 23352KB
stdin
Standard input is empty
stdout
0.01	0.22
0.2	0.34
adf asdf 0.2 asdfasf 1.2	2.3 sdfs