开发者

Regular Expression regex to match start and end of a form with everything inbewteen

<(form)[^>]*method=(['\"])post(['\"]).*</(form)>

Currently i've got that.. which kind of works if there is no new line involved..开发者_JS百科 but I'm not sure how to search for everything (including input fields) inside of the form tag

Any help is appreciated :]


$html = "<form>your form stuff here</form>"

$dom = new DOM;
$dom->loadHTML($html);
$xp = new XPath($dom);

$form = $xp->query('//form')->item(0);

$guts = $form->saveHTML();


HI

$pattern = "/<form\b[^>]*>(.*?)<\/form>/is";


preg_match_all('%<form.*?</form%i', $subject, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[0]); $i++) {
    # Matched text = $result[0][$i];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜