$a = "abc@123 abc"
正则表达式 获取到 @和空格中间的这个字符串
结果应该是 "123"
~坐等

解决方案 »

  1.   

    preg_match('/@(.*?) /',$a,$m);
    echo $m[1];
      

  2.   

    得出来是数组 
    array(2) {
      [0] => string(5) "@asj "
      [1] => string(3) "asj"
    }
      

  3.   

        $a = "132h@asj asd";
        preg_match('/@(.*?) /',$a,$m);
    ehco $m;
    出来是数组型Array
    print_r($m);
    得出来是数组  
    array(2) {
      [0] => string(5) "@asj "
      [1] => string(3) "asj"
    }
        
      

  4.   

    我想直接得出来字符串...
    才看到是你 echo $m[1];
      

  5.   

    [User:root Time:23:10:40 Path:/home/liangdong/php]$ php preg.php 
    Array
    (
        [0] => abc@123
        [1] => 123
    )
    [User:root Time:23:10:40 Path:/home/liangdong/php]$ cat preg.php 
    <?php
    $content = <<<EOF
    abc@123 abc
    EOF;
    $nmatches = preg_match('/\w+@(\w+)/s', $content, $matches);
    print_r($matches);
    ?>