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"[A-Z][a-z]+\s+[A-Z][a-z]+"
  7.  
  8. test_str = ("<html>\n"
  9. "<body>\n"
  10. "<table>\n"
  11. "<tr class=tb1><td>Lorem Ipsum dolor Sit amet</td></tr>\n"
  12. "<tr class=tb1><td>Consectetuer adipiscing elit</td></tr>\n"
  13. "<tr><td>Aliquam Tincidunt mauris eu Risus</td></tr>\n"
  14. "<tr><td>Vestibulum Auctor Dapibus neque</td></tr>\n"
  15. "</table>\n"
  16. "</body>\n"
  17. "</html>\n"
  18. "\"\"\"")
  19.  
  20. matches = re.finditer(regex, test_str, re.MULTILINE)
  21.  
  22. for matchNum, match in enumerate(matches):
  23. matchNum = matchNum + 1
  24.  
  25. print (match.group())
  26.  
  27. # Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
Lorem Ipsum
Aliquam Tincidunt
Vestibulum Auctor