正则匹配指定长度的数字要怎么写?
<td>1234567890</td>
<td>1234567890123</td>
<td>0987654321</td>
<td>3210987654321</td>
<td>1324354657</td>
<td>1324354657689</td>
我只想匹配其中长度为10的那些数字,我要怎么写正则?
[解决办法]
$str=<<<htm<td>1234567890</td><td>1234567890123</td><td>0987654321</td><td>3210987654321</td><td>1324354657</td><td>1324354657689</td>htm;preg_match('/(<td>[\d]{10}<\/td>)/',$str,$match);print_R ($match[1]);
[解决办法]
<?php$str=<<<htm<td>1234567890</td><td>1234567890123</td><td>0987654321</td><td>3210987654321</td><td>1324354657</td><td>1324354657689</td>htm;preg_match_all('/(<td>[\d]{10}\b<\/td>)/',$str,$match);print_R ($match[1]);
[解决办法]
preg_match_all('/<td>(\d{10}\b)<\/td>/',$str,$matchs);print_r ($matchs);
[解决办法]
把函数改成 preg_match_all 就行了
preg_match_all('/(<td>[\d]{10}<\/td>)/',$str,$match);