开发者

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

开发者 https://www.devze.com 2023-03-08 07:22 出处:网络
<(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
<(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

精彩评论

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