1
我想用PHP来提取从以下字符串16197226146
:如何使用PHP/Regex解析Google Voice电子邮件地址?
"(480) 710-6186" <[email protected]>
可能有人请帮助我的正则表达式吗?
我想用PHP来提取从以下字符串16197226146
:如何使用PHP/Regex解析Google Voice电子邮件地址?
"(480) 710-6186" <[email protected]>
可能有人请帮助我的正则表达式吗?
<\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 = "";
}
你可以使用爆炸。
$value = "(480) 710-6186"<[email protected]>";
$result = explode('.', $value);
echo $result[1]; // is 16197226146
+1为工具 – xQbert
完美!是的,谢谢你的工具!我不得不删除'< - - 很棒! – Josiah