private Complex parse_complex(String substring) {

        StringBuilder sb = new StringBuilder(substring);
        Scanner s;
        double r = 0.0;
        double i = 0.0;

        if (sb.charAt(0) == '(') {
            sb.deleteCharAt(0);
        }
        if (sb.charAt(sb.length() - 1) == ')') {
            sb.deleteCharAt(sb.length() - 1);
        }
        if (sb.indexOf("+") > 0) {
            sb.insert(sb.indexOf("+"), " ");
            sb.deleteCharAt(sb.indexOf("+"));
            sb.insert(sb.indexOf("i"), " ");
            s = new Scanner(sb.toString());
            r = s.nextDouble();
            i = s.nextDouble();
        } else if (sb.indexOf("i") > 0) {
            sb.insert(sb.indexOf("i"), " ");
            s = new Scanner(sb.toString());
            i = s.nextDouble();
        } else {
            s = new Scanner(sb.toString());
            r = s.nextDouble();
        }

        Complex c = new Complex(r, i);
        // System.out.println(c.im);
        // System.out.println(c.re);
        return c;
        
    }