正则查询结果<br>\\s*<br>(\\d{2,3}\.\\d{2,3}\.\\d{2,3}\.\\d{2,3})\\s*<br>然后group(1)就行了

解决方案 »

  1.   

    我是刚进入JAVA学习的 
    我刚运行了 
    没有报错 
    运行也没有结果 
    我把代码贴出来: 
    import java.net.*; 
    import java.io.*; 
    import java.util.regex.Matcher; 
    import java.util.regex.Pattern; public class url { 
    public static void main(String args[]) 

    String s; 
    try 

    URL MyURL=new URL("http://www.dheart.net/ip/index.php?ip=122.195.53.130"); 
    BufferedReader dis=new BufferedReader(new InputStreamReader(MyURL.openStream())); 
    s=dis.readLine(); 
    Pattern p=Pattern.compile("查 询 结 果.*? <br>.*? <br>(.*?) <br>"); 
    Matcher m=p.matcher(s); while(m.find()) 

    System.out.println(m.group(1).trim()); 


    catch(MalformedURLException e) 

    System.out.println("URL in wrong from,check it."); 

    catch(IOException e) 

    System.out.println("IO Exception ocurred when get information."); 

    } }