public static int[] parsePortRange(String portrange) throws RuntimeException {

		int[] result = new int[0];

		for (String range : portrange.split(",")) {

			if (range.startsWith("(") && range.endsWith(")")) {
				String[] ranges = range.substring(1, range.length()-1).split("-");

				int i1 = NumberUtils.toInt(ranges[0], -1);
				int i2 = NumberUtils.toInt(ranges[1], -1);

				if (i1 == -1 || i2 == -1)
					throw new RuntimeException("Failed to parse range.");

				if (i2 < i1) {
					int t = i2;
					i1 = i2;
					i2 = t;
				}

				int[] add = new int[i2 - i1];

				for (int i = i1, j = 0; i<i2; i++, j++) {
					add[j] = i;
				}

				result = ArrayUtils.addAll(result, add);

				continue;
			}

			int i = NumberUtils.toInt(range, -1);
			if (i == -1)
				throw new RuntimeException("Failed to parse subip.");

			result = ArrayUtils.add(result, i);
		}

		return result;

	}