1< form name=form_prod action="./conso_cond.php" method="post"><br />
2< form name=open_belg_certif target="_blank" method=post action="./show_certif.php"><br />
3< form method = "get" action=""><br />
4< form><br />
5< form method='get'><br />
6< form name="frm" method='get' action=""><br />
7< form method=get action=""><br />
8< form action=""><br />
9< form action="TT<? echo $p; ?>" method="get"><br />
10< form action="forma<? echo $p; ?>" action="top.php" target="top" method="get"><br />
我希望正则表达式将所有提交的表格设为GET 而不是 POST。这意味着在FORM标签中提到或未提及method =“get”或没有提及。
如果有人想尝试我的代码:
$arr[] = '1< form name=form_prod action="./conso_cond.php" method=post">';
$arr[] = '2< form name=open_belg_certif target="_blank" method=post action="./show_certif.php">';
$arr[] = '3< form method = "get" action="">';
$arr[] = '4< form>';
$arr[] = '5< form method="get">';
$arr[] = '6< form name="frm" method="get" action="">';
$arr[] = '7< form method=get action="">';
$arr[] = '8< form action="">';
$arr[] = '9< form action="TT" method="get">';
$arr[] = '10< form action="forma" action="top.php" target="top" method="get">';
echo '< textarea cols=100 rows=30>';
foreach($arr as $myLine) {
if (preg_match("/[\s]*<[\s]form((.)method=['\"]?get['\"]?).>/", $myLine)) {
echo "\n". trim($myLine);
}
}
echo '< /textarea>';
此代码返回不需要的案例1和2(均为POST)!。提前致谢!
答案 0 :(得分:0)
试试这个正则表达式:
"/\<form(.+?)method=['|\"]get['|\"]/i"