2012-06-07 79 views

回答

4

<\d*?\.(\d+)

< Match "<" 
\d Match digits 
    * 0 or more times 
    ? Lazy, take as little as possible 
\. Match a "." 
( Capture 
    \d Match digits 
    + 1 or more times 
) Stop capturing 

即一个.之后的第二多个相匹配。匹配在组1中。

if (preg_match("/<\d*?\.(\d+)/", $subject, $regs)) { 
    $result = $regs[1]; 
} else { 
    $result = ""; 
} 

You can play with the regex here

+0

+1为工具 – xQbert

+1

完美!是的,谢谢你的工具!我不得不删除'< - - 很棒! – Josiah

0

你可以使用爆炸。

$value = "(480) 710-6186"<[email protected]>"; 

$result = explode('.', $value); 
echo $result[1]; // is 16197226146