$string =  http (80/tcp)
用个正则获取80, 也就是它的端口号。谢谢 

解决方案 »

  1.   

    正则表达式能实现获取字符串中的字符吗?
    正则表达式是用来检查字符串是否满足一定的格式的
    用strpos()和substr()函数可以实现。
      

  2.   

    正则表达式能实现获取字符串中的字符吗?
    正则表达式是用来检查字符串是否满足一定的格式的
    用strpos()和substr()函数可以实现。
      

  3.   

    $str="http (80/tcp)";
    $ze="/^http \((.*)\/tcp\)$/";
    $f=preg_match($ze,$str,$arr);
    print_r($arr);
      

  4.   

    显示结果为:Array ( [0] => http (80/tcp) [1] => 80 ) 
      

  5.   

    $string ="http (80/tcp)";
    preg_match('/\((\w+)\/tcp/',$string,$portArr);
    $port=$portArr[1];
    echo $port;