我有一个正则表达式,应该捕获4个元素,但只能捕获3个。这是代码
<?php
$re = '/<input.+>(.*)</m';
$str = ' <input type="radio" name="562" value="1" onclick> turtle.show() <br>
<input type="radio" name="562" value="2"> turtle.showLocation() <br>
<input type="radio" name="562" value="3"> turtle.showDirection() <br>
<input type="radio" name="562" value="4"> turtle.showturtle() <br><input type="hidden" id="ans562" value="4">';
preg_match_all($re, $str, $matches);
// Print the entire match result
var_dump($matches);
答案 0 :(得分:0)
尝试使用此正则表达式-在懒惰/贪婪的模式下:
$re = '/<input(?:\s.*)?>([^<]*)</mU';