fork download
  1. import re
  2. regex = r"(?:.*(?:\r?\n)+){2}age(?:.*(?:\r?\n|$)+){3}"
  3. test_str = (" Pratap\n"
  4. "pandey\n"
  5. "age\n"
  6. "25\n"
  7. "student")
  8.  
  9. matches = re.finditer(regex, test_str, re.MULTILINE)
  10. for match in matches:
  11. print (match.group())
Success #stdin #stdout 0.04s 9820KB
stdin
Standard input is empty
stdout
 Pratap
pandey
age
25
student