Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-使用正则表达式选择输入类型_Php_Html_Regex - Fatal编程技术网

PHP-使用正则表达式选择输入类型

PHP-使用正则表达式选择输入类型,php,html,regex,Php,Html,Regex,我为标题道歉,我不知道如何恰当地表达它 但问题是: preg_match_all("/ (<input[^>]+>) | <select[^>]+>(.+?)<\/select | <textarea[^>]+>([^<]+) /xims", $form, $matches); 我获取“文本”字段,但没有获取“文件”字段。。 我还想在$matches[]中包含“file”输入类型。 我在正则表达式方面很弱,我在谷

我为标题道歉,我不知道如何恰当地表达它
但问题是:

preg_match_all("/  (<input[^>]+>)  |  <select[^>]+>(.+?)<\/select  |  <textarea[^>]+>([^<]+)  /xims", $form, $matches);

我获取“文本”字段,但没有获取“文件”字段。。

我还想在$matches[]中包含“file”输入类型。

我在正则表达式方面很弱,我在谷歌上搜索了很多,但没有发现任何精确的东西。
谢谢你的回答

试试这个正则表达式:

/(?:<(select|textarea)[^>]*>[^<]+<\/\1>)|(<input[^>]*type=\"([a-z]+)\"[^>]*\/?>)/ximsg
/(?:]*>[^]*\/?>)/ximsg

样本来源:()

$re='/(?:]*>[^]*\/?>)/xims';
$str='1
呜呜呜呜
abc
';
预匹配全部($re,$str,$matches,预设置顺序,0);
var_dump($matches);

检查并更正语法
int preg\u match\u all(string$pattern,string$subject[,array&$matches[,int$flags=preg\u pattern\u ORDER[,int$offset=0]])
()
print_r($matches);
/(?:<(select|textarea)[^>]*>[^<]+<\/\1>)|(<input[^>]*type=\"([a-z]+)\"[^>]*\/?>)/ximsg
$re = '/(?:<(select|textarea)[^>]*>[^<]+<\/\1>)|(<input[^>]*type=\"([a-z]+)\"[^>]*\/?>)/xims';
$str = '<input type="file" name="upload">
<input type="text" name="upload1">
<select > bla bla bla </select>
<textarea>abc</textarea>
';

preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
var_dump($matches);