日期:2014-05-17 浏览次数:20556 次
<?php $str = "<str1>name1</str1><str2>name2</str2>"; $patten = "/<str\d+>([^<]*)<\/str\d+>/isU"; preg_match_all($patten,$str,$matches); print_r($matches[1]);
------解决方案--------------------
$str = "<str1>name1</str1><str2>name2</str2>";
preg_match_all('/>([^<]+)</U', $str, $matches);
print_r($matches[1]);
/**
输出结果:
Array ( [0] => name1 [1] => name2 )
*/
------解决方案--------------------
preg_match_all("/>[^<]+</",$str,$m);
print_R($m[1]);
------解决方案--------------------
$str = "<str1>name1</str1><str2>name2</str2>";
preg_match_all('/>([^<]+)</U', $str, $matches);
print_r($matches[1]);
/**
输出结果:
Array ( [0] => name1 [1] => name2 )
*/
------解决方案--------------------
<?php
$str="<str1>name1</str1><str2>name2</str2>";
$preg="#<str1>(.*)</str1><str2>(.*)</str2>#";
preg_match($preg,$str,$arr);
echo $arr[1];
echo $arr[2];
?>
------解决方案--------------------
<?php
$str="<str1>name1</str1><str2>name2</str2>";
preg_match_all("/<[a-z0-9]*>([^<|>]*)<\/[a-z0-9]*>/",$str,$matches);
echo $matches[1][0];
echo $matches[1][1];
?>
------解决方案--------------------
"/>(.*?)<\//"
------解决方案--------------------