fork download
  1. import re
  2.  
  3. regex = r"\r?\ndescription: \"([^\"]+)\"(?:\r?\n(?!newDate\.setFullYear\().*)*\r?\nnewDate\.setFullYear\(([^()]+)\);"
  4.  
  5. test_str = ("chartData.push({\n"
  6. "date: newDate,\n"
  7. "visits: 9710,\n"
  8. "color: \"#016b92\",\n"
  9. "description: \"9710\"\n"
  10. "});\n"
  11. "var newDate = new Date();\n"
  12. "newDate.setFullYear(\n"
  13. "2007,\n"
  14. "10,\n"
  15. "1 );")
  16.  
  17. print (re.findall(regex, test_str))
Success #stdin #stdout 0.02s 9508KB
stdin
Standard input is empty
stdout
[('9710', '\n2007,\n10,\n1 ')]