当前位置:Gxlcms > PHP教程 > 正则匹配有关问题求指教

正则匹配有关问题求指教

时间:2021-07-01 10:21:17 帮助过:3人阅读

正则匹配问题 求指教
获取一个A标签的Href属性

被匹配的字符

连接1
连接2
连接3


可以没有引号 可以有双引号 单引号 但是不允许一侧有引号另一侧没有引号

PHP code
preg_match('//i', $str, $matches)




这样怎么不行呢

------解决方案--------------------
PHP code
$str=<<]*>/',$str,$matches);
print_r($matches[2]);

------解决方案--------------------
PHP code
$str=<<------解决方案--------------------
PHP code
[User:root Time:14:14:52 Path:/home/liangdong/php]$ php preg.php 
Array
(
    [0] => Array
        (
            [0] =>    Array
        (
            [0] => "
            [1] => '
            [2] => 
        )

    [2] => Array
        (
            [0] => http://www.baidu.com/
            [1] => http://www.baidu.com/
            [2] => http://www.baidu.com/
        )

)
[User:root Time:14:14:53 Path:/home/liangdong/php]$ cat preg.php 


                  

	 	
                    
                    
                    
                    
                    
                

人气教程排行