1.从字符串中查找某个特定字符串,然后替换.
this.sectionName=sectinInfo.sectionName;
Matcher matcher=Pattern.compile("(\\d{1,3})[.{jpg},{gif},{png}]").matcher(sectinInfo.firstpageURL);if (matcher.find())
if(matcher.group(1).indexOf('0')>-1)
pageURL=sectinInfo.firstpageURL.replace(matcher.group(1),String.format("%03d", index));
else{
pageURL=sectinInfo.firstpageURL.replace(matcher.group(1),index+"");
}
2.格式化字符串
String.format("%03d", index)
字符串显示4位,前面补充0.
3.int转换string的小方法: string "1"=1+"";