From: Johnson Wang <99100@163.com> Date: 2007-11-10T01:00:59+09:00 Subject: Re: a problem related string(250 score) C辿dric Finance wrote: > The argument of the split method in java is a string representing a > regexp. > So you can do this: str.split("X+"); Yes,u r right,Mr C辿dric Finance.I am so stupid,i misunderstood the meaning of CharSequence.Appreciate your help,tks very much!!! -------------------------------------------------------------- public String[] split(String regex, int limit) { return Pattern.compile(regex).split(this, limit); } -------------------------------------------------------------- public String[] split(CharSequence input, int limit) { int index = 0; boolean matchLimited = limit > 0; ArrayList matchList = new ArrayList(); Matcher m = matcher(input); // Add segments before each match found while(m.find()) { if (!matchLimited || matchList.size() < limit - 1) { String match = input.subSequence(index, m.start()).toString(); matchList.add(match); index = m.end(); } else if (matchList.size() == limit - 1) { // last one String match = input.subSequence(index, input.length()).toString(); matchList.add(match); index = m.end(); } } ............. -- Posted via http://www.ruby-forum.com/.