我有输出字符串
Reg. Contact : sip:2001@192.168.50.138:5089;line=6640f2cd1b461a5
我只想要@和之间的IP地址.string。我怎么能得到它?
答案 0 :(得分:2)
尝试这样的事情:
<?php
$input = "Reg. Contact :sip:2001@192.168.50.138:5089;line=6640f2cd1b461a5";
preg_match('~@(.*?):~', $input, $output);
echo $output[1];
?>
答案 1 :(得分:1)
<?php
$str="Reg. Contact :sip:2001@192.168.50.138:5089;line=6640f2cd1b461a5";
$start=strpos($str,"@");
$end= strrpos($str,":");
$len=$end-$start;
echo substr($str,$start+1,$len-1);
?>