62,616
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
String s1="<SPAN style='COLOR: #008000'>28.28</SPAN>";
List<String> resultList = getRegExpValsList(s1,"(?is)color.+?>(?!10{2}\\s+)(?=[1-2]\\d{2}[\\d\\.]*)([\\d\\.]+)"); //关键我是不知怎么调这句正则表达式,才会打印28.28
for(String tmpS:resultList )
(
System.out.println(resultList);
}
}
public static List<String> getRegExpValsList(String regExp, String oriStr) {
List<String> rtn=new ArrayList<String>();
Matcher m=Pattern.compile(regExp).matcher(oriStr);
while(m.find()){
if(m.group(1)!=null)
{
rtn.add(m.group(1));
}
}
return rtn;
}
public static void main(String[] args) {
//String s="<SPAN style="COLOR: #ff0000">268.28</SPAN>";
String regex = "\\.*\\d{3}.\\d{2}\\.*";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(">268.28<");
if(m.find()) {
System.out.println(m.group());
}
}
String s = "<SPAN style=\"COLOR: #ff0000\">268.28</SPAN>";
System.out.println(s.replaceAll("^.*(\\d{3}\\.\\d{2}).*", "$1"));