class RequestUtils {

    public static List<Request> from(String exp){
        Matcher matcher = p4Range.matcher(exp);
        if (!matcher.find()) {
            return Collections.singletonList(new Request(exp));
        }
        int rangeFrom = Integer.parseInt(matcher.group(1));
        int rangeTo = Integer.parseInt(matcher.group(2));
        if (rangeFrom > rangeTo) {
            return Collections.emptyList();
        }
        List<Request> requests = new ArrayList<Request>(rangeTo - rangeFrom + 1);
        for (int i = rangeFrom; i <= rangeTo; i++) {
            requests.add(new Request(matcher.replaceAll(String.valueOf(i))));
        }
        return requests;
    }

}

class RequestUtilsTest {

    @Test
    public void test_generate_range_when_invalid_number() throws Exception {

        List<Request> requests = RequestUtils.from("http://angularjs.cn/api/article/latest?p=[10-3]&s=20");
        assertThat(requests).isEmpty();
    }

}