【发布时间】:2014-10-16 16:18:31
【问题描述】:
我有 $input,其中包含:
<a href="http://digitalocean.com/info/hello-23-kitty-show-1-d-zay-ya-9013294119" title="Hello Kitty (Show & Zay Ya" style="font-size:medium;" target="_blank" class="highlight-item">
我需要 preg_match 仅在 href url (9013294119) 中的最后一个数字。这些数字有时会更长或更短,因为 $input 中的 URL 会有所不同(但其长度始终至少为 4 个字符)。
我尝试了以下正则表达式,但没有运气,因为我的正则表达式经验非常有限:
preg_match('/^[0-9+]$/', $input, $output);
有什么帮助吗?
【问题讨论】:
标签: php regex preg-match