<?
$str = "abc.xsl adsf.htm asdfkjid.html asdflkj dsf.htm sdfj af.xsl";
preg_match_all("/[^[\.htm]]|\.html|\.xsl/isU", $str, $ar);
print_r($ar);
?>
拿去看吧。

解决方案 »

  1.   

    楼上误会楼主意思了这种情况要用到断言:
    $str = "adsf.HTM";
    if(preg_match("/(?<!\.html|\.xsl|\.htm)$/is",$str)) echo "匹配";
    else echo "不匹配";
      

  2.   

    主要起作用的是?<!,约束某字符前面不能为某字符串
    比如:
    (?<!str1)str就是匹配str前面不为str1的字符串,对于你的情况,这里的str就是结尾匹配符号$,str1就是\.html|\.xsl|\.htm看看php文档就明白了
      

  3.   

    楼主运行一下我的代码就明白了。
    我没有把三个条件都成立,我只不显示.htm的,其它的就看你楼主怎么用了。
      

  4.   

    [^[\.htm]]
    楼上你能说说你这部分是什么意思吗?
      

  5.   

    Array
    (
        [0] => Array
            (
                [0] => .xsl
                [1] => .html
                [2] => .xsl
            ))
    显然不对$str = "abc.xsl adsf.htm asdfkjid.html asdflkj dsf.htm sdfj.txt af.xsl";
    print_r(preg_split("/[^\s]+\.(html?|xsl)/",$str));
    Array
    (
        [0] => 
        [1] =>  
        [2] =>  
        [3] =>  asdflkj 
        [4] =>  sdfj.txt 
        [5] => 
    )
    这样才马马乎乎
      

  6.   

    $str = "abc.xsl adsf.htm asdfkjid.html asdflkj dsf.htm sdfj af.xsl";$ar = array();
    function test($s) {
      if(! preg_match("/\.(html?|xsl)/",$s))
        $GLOBALS['ar'][] = $s; 
    }preg_replace("/([^ ]+)/e","test('$1')",$str);print_r($ar);
      

  7.   

    <?
    $str = "abc.xsl adsf.htm asdfkjid.html asdflkj fjdsl.txt dsf.htm sdfj af.xsl";
    preg_match_all("/(?<=\s|^)(?:(?:[^\s](?!\.htm|\.html|\.xsl))*)(?=\s|$)/is", $str, $ar);
    print_r($ar);
    ?>
      

  8.   

    re=/.+\.htm|.+\.html|.+\.xsl/
    if(str.search(re)!=-1)
    {
    alert("不符合条件");
    }
    else
    {
    alert("符合条件");
    }
      

  9.   

    上面的re应该是这个re=/.+\.htm$|.+\.html$|.+\.xsl$/
      

  10.   

    <?
    $str = "abc.xsl adsf.htm asdfkjid.html asdflkj fjdsl.txt dsf.htm sdfj af.xsl";
    preg_match_all("/(?<=\s|^)(?:(?:[^\s](?!\.htm|\.html|\.xsl))*)(?=\s|$)/is", $str, $ar);
    print_r($ar);
    ?>
    输入结果:Array
    (
        [0] => Array
            (
                [0] => asdflkj
                [1] => fjdsl.txt
                [2] => sdfj
            ))
    若是要以上结果正确,可以散分了