日期:2014-05-20 浏览次数:20647 次
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Demo {
public static void main(String[] args) {
String first = "Cc001";
String last = "Cc00200";
betweenStr(first, last);
}
public static void betweenStr(String first, String last) {
String prefix = null;
Matcher m = Pattern.compile("(.*)([^0])").matcher(last);
if (m.find()) {
prefix = m.group(1);
}
int begin = Integer.parseInt(first.replace(prefix, ""));
int end = Integer.parseInt(last.replace(prefix, ""));
for (int i = begin + 1; i < end; i++) {
System.out.println(prefix + i);
}
}
}