code: def strip_line_magic_v2(cls,line):
          
  
          matches = re.findall("magic\(([^]]+)", line)
          if matches and matches[0]: # This line contains the pattern
              match = matches[0]
              if match[-1] == ')':
                  match = match[:-1] # Just because the re way is hard
              stripped = eval(match)
              magic_kind = stripped.split(' ')[0]
              if len(stripped.split(' '))>1:
                  stripped = stripped.split(' ')[1:]
              else:
                  stripped = ""
          else:
              stripped = line
              magic_kind = ""
          return stripped,magic_kind
docs: strip_line_magic() implementation for Python 2