I'l*_*ack 1 php regex preg-match
我试图从transaction(123456)HTML中获取ID
它似乎没有返回任何东西.
$response = "</body> </html><script type='text/javascript'>transaction(123456);</script>";
preg_match('/^transaction\((\d+)\)/', $response, $match);
print_r($match);
if (is_numeric($match[1])) {
echo "Your ID: " . $match[1];
}
Run Code Online (Sandbox Code Playgroud)
因为你有字符串锚的开头^,并且transaction(不在字符串的开头.删除(或添加非贪婪的匹配),它将工作(如此演示所示):
preg_match('/transaction\((\d+)\)/', $response, $match);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1574 次 |
| 最近记录: |