code: public static RangeSet merge(RangeSet rs)
      {
          RangeSet result = new RangeSet();
          int from = -1;
          int to = -1;
          for (CharRange r : rs)
          {
              if (from == -1) // first
              {
                  from = r.getFrom();
                  to = r.getTo();
              }
              else
              {
                  if (r.getFrom() == to)
                  {
                      to = r.getTo();
                  }
                  else
                  {
                      result.add(from, to);
                      from = r.getFrom();
                      to = r.getTo();
                  }
              }
          }
          result.add(from, to);
          return result;
      }
docs: Returns a new RangeSet that accepts the same characters as argument.
  Ranges that are followinf each other are concatenated.
  @param rs
  @return