@Override
   public Polinome parsePolinome(String input) {
      Polinome polinom = new Polinome();

      String[] negativeGroups = input.split("[-]");
      List<String> monoms = new ArrayList<String>();
      int index = 0;
      Integer exponent;
      Integer coeficient;

      for (String g : negativeGroups) {
         if (g.isEmpty()) {
            continue;
         }
         String[] groupMonoms = g.split("[+]");

         for (int j = 0; j < groupMonoms.length; ++j) {
            monoms.add(j == 0 ? "-" + groupMonoms[j] : groupMonoms[j]);
         }
      }

      if (!"-".equals(input.substring(0, 1))) {
         monoms.set(0, monoms.get(0).replace("-", ""));
      }
      for (int i = 0; i < monoms.size(); i++) {
         monoms.set(i, convertToGeneralForm(monoms.get(i)));
      }
      for (String g : monoms) {
         String[] coef = g.split("[x]+");
         coeficient = Integer.parseInt(coef[0]);
         exponent = Integer.parseInt(coef[1]);
         polinom.setMonome(exponent, coeficient);
      }

      return polinom;
   }