Rumah > Artikel > pembangunan bahagian belakang > 如上,小弟我是想要结果为 12abc34
如上,我是想要结果为 12abc34
$string = "some text (12abc34) more text";
if(preg_match("/[(][.][)]/",$string,$matches)){
echo $matches;
}
?>
如上,我是想要结果为 12abc34
------解决方案--------------------
$string = "some text (12abc34) more text";
preg_match('/\(([a-z0-9]+)\)/', $string, $matches);
echo $matches[1];
------解决方案--------------------
$string = "some text (12abc34) more text";
$preg = "/\d+.*\d+/";
preg_match($preg, $string, $matches);
var_dump($matches);
试试这个