fork download
  1. # your code goes here
  2. import re
  3.  
  4. regex = r"document\.write\(function\(\s*'([^']+)'\s*,\s*'([^']+)'\s*\)"
  5.  
  6. test_str = ("<html>\n"
  7. "<!--Some html code-->\n"
  8. "document.write(function('variable1', 'variable2'));\n"
  9. "<!--Some html code-->\n"
  10. "</html>")
  11.  
  12. matches = re.finditer(regex, test_str)
  13.  
  14. for matchNum, match in enumerate(matches):
  15. matchNum = matchNum + 1
  16.  
  17. for groupNum in range(0, len(match.groups())):
  18. groupNum = groupNum + 1
  19.  
  20. print ("{group}".format(group = match.group(groupNum)))
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
variable1
variable2