### Question:
SqlObject extends PagingQueryConfig { public static String removeOrderBy(String queryString) { int index = queryString.indexOf("!!order"); if (index != -1) { return queryString.substring(0, index); } else { int last_index_or = queryString.lastIndexOf("order by"); int last_index_ = queryString.lastIndexOf(")"); if (last_index_ > last_index_or) { return queryString; } Pattern p = Pattern.compile("order\\s*by[\\w|\\W|\\s|\\S]*", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(queryString); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, ""); } m.appendTail(sb); return sb.toString(); } } SqlObject();  SqlObject(String sql, List<Object> args); String getNativeSql(Condition condition); String getNativeSql(); String getSql(Condition condition); String getSql(); SqlObject<T> setSql(String sql); RowMapper<T> getRowMapper(); SqlObject<T> setRowMapper(RowMapper<T> rowMapper); SqlObject<T> setSelect(String select); String getSelect(); String getFrom(); SqlObject<T> setFrom(String from); SqlObject<T> setWhere(String where); void setGroupBy(String groupBy); SqlObject<T> setOrderBy(String orderBy); String getCountSql(Condition condition); String getFromWhereSql(Condition condition); String getFromWhereSql(); static String removeOrderBy(String queryString); static String removeSelect(String queryString); List<Object> getArgs(); SqlObject<T> setArgs(List<Object> args); @Override List<Object> getTotalnumQueryParams(Condition condition); @Override String getQueryString(Condition condition); @Override String getTotalnumQueryString(Condition condition);  }### Answer:
@Test public void testRemoveOrderBy01() { String sql = "select a,b from c where a=1 order by a asc"; Assert.assertEquals("select a,b from c where a=1 ", SqlObject.removeOrderBy(sql)); }
@Test public void testRemoveOrderBy04() { String sql = "select a,(select a,b from d where b=1 order by b) from c where a=1 order by a asc"; Assert.assertEquals("select a,(select a,b from d where b=1 ", SqlObject.removeOrderBy(sql)); }
@Test public void testRemoveOrderBy02() { String sql = "select a,b from c where a=1 $$order by a asc"; Assert.assertEquals("select a,b from c where a=1 ", SqlObject.removeOrderBy(sql)); }
@Test public void testRemoveOrderBy03() { String sql = "select a,(select a,b from d where b=1 order by b) from c where a=1 $$order by a asc"; Assert.assertEquals( "select a,(select a,b from d where b=1 order by b) from c where a=1 ", SqlObject.removeOrderBy(sql)); }