System.out.println(s.split(" ")[1]);或者System.out.println(s.split("\\s")[1]);
System.out.println(s.split("\\s+")[1]);
int begin = s.indexOf(" ");
int end = s.indexOf(" ", begin+1);
System.out.println(s.substring(begin+1, end));
public class RegExp {
public boolean match(String reg, String str) {
return Pattern.matches(reg, str);
}
public List<String> find(String reg, String str) {
Matcher matcher = Pattern.compile(reg).matcher(str);
List<String> list = new ArrayList<String>();
while (matcher.find()) {
list.add(matcher.group());
}
return list;
}
public String find(String reg, String str, int index) {
Matcher matcher = Pattern.compile(reg).matcher(str);
if (matcher.find()) {
return matcher.group(index);
}
return null;
}
public String findString(String reg, String str) {
String returnStr = null;
List<String> list = this.find(reg, str);
if (list.size() != 0)
returnStr = list.get(0);
return returnStr;
}
}
RegExp re = new RegExp();
System.out.println(re.findString("\\d+", s));
System.out.println(re.findString("(?<=共).*?\\d+", s).trim());
System.out.println(s.replaceFirst(".*?(\\d+).*", "$1"));
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有