Php 使用preg match all匹配代码
我正在使用preg match all标记为匹配代码编写一个php 这是我的php代码Php 使用preg match all匹配代码,php,preg-match-all,Php,Preg Match All,我正在使用preg match all标记为匹配代码编写一个php 这是我的php代码 preg_match_all('|SentSmsId(\d*?)&noOfMessages|i', $data, $code); 回显“$code” 下面是html代码 <a href="sentSms.php?zxcoiesesscd=&SentSmsId=8830978&NoOfMessages=" style="text-decoration:none;" 您的正
preg_match_all('|SentSmsId(\d*?)&noOfMessages|i', $data, $code);
回显“$code”
下面是html代码
<a href="sentSms.php?zxcoiesesscd=&SentSmsId=8830978&NoOfMessages=" style="text-decoration:none;"
您的正则表达式中缺少=
preg_match_all('|SentSmsId=(\d*?)&noOfMessages|i', $data, $code);
print_r($code);
您需要考虑以下因素:
e、 g.SentSmsId\=(\d*?)&noOfMessages当$data中包含多个代码时:
preg_match_all('~SentSmsId=\K\d++(?=&noOfMessages)~', $data, $codes);
print_r($codes);
但如果您只查找1个代码,则最好使用preg_match。谢谢。。。我错过了……:)