我现在有这样一段文本null;http://www.25175.com/200609null;http://www.25175.com/200609/index.aspx;http://www.25175.com/200609/25175/25175_program;http://www.25175.com/200609/25175/25175_asp_psd;http://www.25175.com/200609/25175/25175_asp_code;http://www.25175.com/200609/25175/25175_asp_tech;http://www.25175.com/200609/25175/25175_asp_tools;http://www.25175.com/200609/25175/25175_asp_book;http://www.25175.com/200609/25175/webjavas;http://www.25175.com/200609/25175/25175_asp_all;http://www.25175.com/200609/25175/school/asp;http://www.25175.com/200609/25175/25175_asp_hero;全是由url组成的
现在我想提取出 包含有[ http://www.25175.com/200609/25175]的 url
 这个正则表达式该如何写呢??在线急等

解决方案 »

  1.   


    <script type="text/javascript">
    <!--
    var str = "null;http://www.25175.com/200609null;http://www.25175.com/200609/index.aspx;http://www.25175.com/200609/25175/25175_program;http://www.25175.com/200609/25175/25175_asp_psd;http://www.25175.com/200609/25175/25175_asp_code;http://www.25175.com/200609/25175/25175_asp_tech;http://www.25175.com/200609/25175/25175_asp_tools;http://www.25175.com/200609/25175/25175_asp_book;http://www.25175.com/200609/25175/webjavas;http://www.25175.com/200609/25175/25175_asp_all;http://www.25175.com/200609/25175/school/asp;http://www.25175.com/200609/25175/25175_asp_hero; "; var reg = /http:\/\/www.25175.com\/200609\/25175[^;]*/g; while((result = reg.exec(str)) != null){
    document.write(result[0]+"<br/>")
    }
    //-->
    </script>
      

  2.   

    var s = "null;http://www.25175.com/200609null;http://www.25175.com/200609/index.aspx;http://www.25175.com/200609/25175/25175_program;http://www.25175.com/200609/25175/25175_asp_psd;http://www.25175.com/200609/25175/25175_asp_code;http://www.25175.com/200609/25175/25175_asp_tech;http://www.25175.com/200609/25175/25175_asp_tools;http://www.25175.com/200609/25175/25175_asp_book;http://www.25175.com/200609/25175/webjavas;http://www.25175.com/200609/25175/25175_asp_all;http://www.25175.com/200609/25175/school/asp;http://www.25175.com/200609/25175/25175_asp_hero; ";
    var a = s.match(/http:\/\/www\.25175\.com\/200609\/25175.+?(?=;)/g);
    alert(a.join("\r"));
      

  3.   

    import java.util.regex.*;public class RegexTest { /**
     * @param args
     */
    public static void main(String[] args) {
    String str="null;" +
    "http://www.25175.com/200609null;" +
    "http://www.25175.com/200609/index.aspx;" +
    "http://www.25175.com/200609/25175/25175_program;" +
    "http://www.25175.com/200609/25175/25175_asp_psd;" +
    "http://www.25175.com/200609/25175/25175_asp_code;" +
    "http://www.25175.com/200609/25175/25175_asp_tech;" +
    "http://www.25175.com/200609/25175/25175_asp_tools;" +
    "http://www.25175.com/200609/25175/25175_asp_book;" +
    "http://www.25175.com/200609/25175/webjavas;" +
    "http://www.25175.com/200609/25175/25175_asp_all;" +
    "http://www.25175.com/200609/25175/school/asp;" +
    "http://www.25175.com/200609/25175/25175_asp_hero; ";
    String regex="(?<=;)http://www.25175.com/200609/25175.*?(?=;)";
    Pattern p=Pattern.compile(regex);
    Matcher m=p.matcher(str);
    while(m.find()){
    System.out.println(m.group());
    }
    }}测试结果:http://www.25175.com/200609/25175/25175_program
    http://www.25175.com/200609/25175/25175_asp_psd
    http://www.25175.com/200609/25175/25175_asp_code
    http://www.25175.com/200609/25175/25175_asp_tech
    http://www.25175.com/200609/25175/25175_asp_tools
    http://www.25175.com/200609/25175/25175_asp_book
    http://www.25175.com/200609/25175/webjavas
    http://www.25175.com/200609/25175/25175_asp_all
    http://www.25175.com/200609/25175/school/asp
    http://www.25175.com/200609/25175/25175_asp_hero
      

  4.   

     String regex="(? <=;)http://www.25175.com/200609/25175.*?(?=;)";