正则表达式查找输入值
regex find input value
字符串是:
<input type="hidden" name="billing[address_id]" value="34543" id="billing:address_id" />
如何从这个字符串中获取输入值?
我试过这段代码:
preg_match('/<input type="hidden" name="billing[address_id]" value="(.*?)" id="billing:address_id" \/>/mis', $html, $results);
你的正则表达式几乎是正确的.. 只需在 address_id.
处转义 [
和 ]
preg_match('/<input type="hidden" name="billing\[address_id\]" value="(.*?)" id="billing:address_id" \/>/mis', $html, $results);
字符串是:
<input type="hidden" name="billing[address_id]" value="34543" id="billing:address_id" />
如何从这个字符串中获取输入值? 我试过这段代码:
preg_match('/<input type="hidden" name="billing[address_id]" value="(.*?)" id="billing:address_id" \/>/mis', $html, $results);
你的正则表达式几乎是正确的.. 只需在 address_id.
处转义[
和 ]
preg_match('/<input type="hidden" name="billing\[address_id\]" value="(.*?)" id="billing:address_id" \/>/mis', $html, $results);