求教正则写法
$str = '
-
莫名
粉丝:932
风险投资人
-
逸仙
粉丝:993
财经
-
称王
粉丝:1093
IT
';
这段字符串怎么匹配出每个li的url,imgurl,name,fans,job,如第一
应该分别匹配出http://aaa.com/iclock, /images/j22.jpg,莫名,932,风险投资人
------解决方案--------------------
PHP code
[User:root Time:06:22:25 Path:/home/liangdong/php]$ php preg.php
Array
(
[0] => Array
(
[0] =>
登录后复制
莫名
粉丝:932
风险投资人
[1] => http://aaa.com/moming
[2] => /images/j22.jpg
[3] => 莫名
[4] => 粉丝:932
[5] => 风险投资人
)
[1] => Array
(
[0] =>
逸仙
粉丝:993
财经
[1] => http://aaa.com/yxian
[2] => /images/j7.jpg
[3] => 逸仙 粉丝:993
[5] => 财经
)
[2] => Array
(
[0] =>
称王
粉丝:1093
IT
[1] => http://aaa.com/ikco
[2] => /images/j2.jpg
[3] => 称王
[4] => 粉丝:1093
[5] => IT
)
)
[User:root Time:06:22:26 Path:/home/liangdong/php]$ cat preg.php
莫名
粉丝:932
风险投资人
逸仙
粉丝:993
财经
称王
粉丝:1093
IT
EOF;
$n = preg_match_all('/
.*.*.*.*.*.*(.*).*(.*).*(.*).*/iUs', $str, $matches, PREG_SET_ORDER);
if ($n) {
print_r($matches);
}
?>