继我最近关于HTML正则表达式的问题已经在这里得到解答(谢谢大家),我决定最后一次坚持使用正则表达式。 我的目标是使用cURL从下面的HTML代码抢值updateXXXX:正则表达式需要删除不需要的字符
(...)<input type="hidden" id="_postupdate" name="_postupdate" value="updateXXXX" /><input type="hidden"(...)
使用
$regex = '/name="_postupdate" value="([^"]*)" \/><input type="hidden"/s';
if (preg_match($regex, $page, $list))
echo $list[0];
我设法得到这种输出:
name="_postupdate" value="updateXXXX" />
我确定有一个简单的方法可以删除:
name="_postupdate" value="
和
" />
再次,感谢所有的建议和帮助:)
你不能使用DOM解析器吗? – elclanrs
我需要这个只是一个小脚本:)谢谢 – Kris