需求不明确.
你要匹配什么?
如果只是查找ABCD,根本用不到正则.

解决方案 »

  1.   

    我是想在editplus的“在文件中查找”符合条件的内容。
    比如我要查找“ABCD”(这个是固定的某个字符串),但是又不想查找的结果里包含“/”这个字符。
    请问要如何查找?
      

  2.   

    preg_match_all("/([^\/]+ABCD[^\/]+)/i", $str, $matches);
    var_dump($matches);
      

  3.   

    正则似乎不能匹配“不是某个字符串”的字符串。分两步匹配的话,可以$s='13fgkjfweriabcdetoyp/e';
    $p1='/abcd/';
    $p2='/9/';
    if(!preg_match($p2,$s,$m) && preg_match($p1,$s,$m))
    echo $m[0];
    在editplus里,是否可以通过录制宏来实现两步搜索(只是个设想,呵呵)
      

  4.   

    3楼的似乎不对。
    /([^\/]+ABCD[^\/]+)/ 这个模式并不能规定abcd之前或之后 不存在'/',只是规定,abcd前后,至少有1个字符不是'/'
      

  5.   

    $s1 = "ABCD /";
    $s2 = "ABCD .xml";
    preg_match_all("/([^\/]+ABCD[^\/]+)/i", $s1, $matches); 
    var_dump($matches);
    preg_match_all("/([^\/]+ABCD[^\/]+)/i", $s2, $matches); 
    var_dump($matches);我用这个测试,打印出的$matches 似乎是2个元素为空的数组。4楼的同学说的,--正则似乎不能匹配“不是某个字符串”的字符串。--
    其实我就是想排除一个特殊字符“/”,不是字符串,应该用^就可以的吧再次谢谢各位啦
      

  6.   

    我4楼写差了:写成数字9了$s='13fgkjfweriabcdetoyp/e';
    $p1='/abcd/';
    $p2='/\//';
    if(!preg_match($p2,$s,$m) && preg_match($p1,$s,$m))
        echo $m[0];
      

  7.   

    很简单,再加个开头结尾就好了.
    $s='13fgkjfweriabcdetoype';
    if(!preg_match("/^([^\/]+ABCD[^\/]+)$/i", $s, $matches))
    {
    echo "不匹配";
    }
    else
    {
    echo "匹配";
    }
      

  8.   


    “/”也是字符串,只不过含有一个字符罢了。
    我觉得,你说的问题,不在于是否[^]的使用,而是你的匹配问题涉及到一个“与”条件的匹配,即,满足条件1,且满足条件2,这如果用一个匹配模式,通过一次匹配匹配出来,似乎不太可能(也可能我学的不精)。
    就我知道,php到是支持条件匹配,格式是:(?(condition)yespattern|nopattern)但editplus,不支持,
    editplus的正则描述里,只支持选择匹配,就是'|'操作:
    ---------edit plus Regular Expression----------
    Expression Description 
    \t Tab character. 
    \n New line. 
    . Matches any character. 
    | Either expression on its left and right side matches the target string. For example, "a|b" matches "a" and "b". 
    [] Any of the enclosed characters may match the target character. For example, "[ab]" matches "a" and "b". "[0-9]" matches any digit. 
    [^] None of the enclosed characters may match the target character. For example, "[^ab]" matches all character EXCEPT "a" and "b". "[^0-9]" matches any non-digit character. 
    * Character to the left of asterisk in the expression should match 0 or more times. For example "be*" matches "b", "be" and "bee". 
    + Character to the left of plus sign in the expression should match 1 or more times. For example "be+" matches "be" and "bee" but not "b". 
    ? Character to the left of question  in the expression should match 0 or 1 time. For example "be?" matches "b" and "be" but not "bee". 
    ^ Expression to the right of ^ matches only when it is at the beginning of line. For example "^A" matches an "A" that is only at the beginning of line. 
    $ Expression to the left of $ matches only when it is at the end of line. For example "e$" matches an "e" that is only at the end of line. 
    () Affects evaluation order of expression and also used for tagged expression. 
    \ Escape character. If you want to use character "\" itself, you should use "\\". --------------------
      

  9.   

    呵呵,我没玩过editplus,只是站在php的角度上来年问题.
    所以...
      

  10.   

    看来是php里可以,editplus里不可以
    谢谢两位的解答,结贴!