<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
0
</body>
</html>从上面的字符串中取出0值

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【xcmxjge】截止到2008-07-22 17:51:40的历史汇总数据(不包括此帖):
    发帖的总数量:24                       发帖的总分数:440                      每贴平均分数:18                       
    回帖的总数量:41                       得分贴总数量:9                        回帖的得分率:21%                      
    结贴的总数量:24                       结贴的总分数:440                      
    无满意结贴数:2                        无满意结贴分:140                      
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:8.33  %               无满意结分率:31.82 %                  
    敬礼!
      

  2.   

    这不需要正则表达式吧。
    直接使用String对象的indexOf("0")就得到0的位置了。
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> 
    <title>Insert title here </title> 
    </head> 
    <body> 
    不定的值
    </body> 
    </html> 
    我怎么通过正则表达式把,<body>和</body>中间的串(就是那个不定的值)拿到呢?如:
    String s="<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> 
    <title>Insert title here </title> 
    </head> 
    <body> 
    不定的值
    </body> 
    </html>";我要大家帮忙我怎么处理这个s字符串
    我要的结果是:String value=不定的值
      

  4.   


    class Test {    public static void main(String args[]) {
           String s=" <!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'><html><head><meta http-equiv='Content-Type' content='text/html; charset=GB18030'><title>Insert title here </title></head><body>不定的值</body></html>"; 
           int index1=s.indexOf("<body>");
           int index2=s.indexOf("</body>");
           String value=s.substring(index1+"<body>".length(), index2);
            System.out.println(value);
        }
    }输出:
    不定的值
      

  5.   

    再写个看着恶心的:class SplitTest {    public static void main(String args[]) {
            String s = " <!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'><html><head><meta http-equiv='Content-Type' content='text/html; charset=GB18030'><title>Insert title here </title></head><body>不定的值</body></html>";
            String test[] = s.split("<body>");//使用<body>将字符串分为两部分,其中<body>之后的部分在test[1]中
            String test2[] = test[1].split("</body>");//使用</body>把test[1]分为两部分,其中test2[0] 为所求的值,test2[1]为</body>之后的部分,不需要处理了
            String value=test2[0];//这就是所求的value
            System.out.println(value);
        }
    }
      

  6.   

    估计楼主这段 HTML 代码是交给 AJAX 中的 XMLHTTPRequest 对象处理的,真要是这样那直接让服务器端的 JSP 页或 Servlet 直接生成只包含 0 等数据的代码岂不是更简单。
      

  7.   


    public static void do10(){
    String str="<body>dsfdas</body>";
    Pattern pattern = Pattern.compile("<body>([^<]+)</body>",Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
    Matcher m = pattern.matcher(str);
    while(m.find()){
    System.out.println(m.group(1));
    }
    }