日期:2014-05-20  浏览次数:20655 次

请教大家一个字符串问题。请进。。。
文本文件中内容如下:
.... <td   width= "20% "   bgcolor= "#EEEEEE "   height= "25 "   align= "right "> <b> <font   color= "#0000FF "> 2007-03-31 <.....
<td   width= "20% "   bgcolor= "#EEEEEE "   height= "25 "   align= "right "> <b> <font   color= "#0000FF "> 2006-12-31 <.....
<td   width= "20% "   bgcolor= "#FFFFFF "   height= "25 "   align= "right "> 295,644 <......
<td   width= "20% "   bgcolor= "#FFFFFF "   height= "25 "   align= "right "> 406,233 <.....
    我想提取2007-03-31、2006-12-31、295,644、406,233怎么写这段程序?怎样用indexOf检索字符串和用subString来截取?
请指教!

------解决方案--------------------
参考这几个方法
indexof
charAt
stringtokenizer
------解决方案--------------------
可以参考commons-lang
------解决方案--------------------
String str = " <td width=\ "20%\ " bgcolor=\ "#FFFFFF\ " height=\ "25\ " align=\ "right\ "> 295,644 <...... ";
Pattern p = Pattern.compile( " <td.+> (.+) <.+ ");
Matcher m = p.matcher(str);
if(m.matches()){
System.out.println(m.group(1));
}