php正则表述

WBOY
WBOYOriginal
2016-06-13 12:51:17823browse

php正则表达
怎么写一个正则,同时匹配两种标签
$pattern="#(\)#U";
$pattern="#(\.*\)#U";
像上面两,分别匹配了input和select。如何把它们合并成一个,只要满足其中一种都行。因为需要按照标签的顺序输出,所以不能分成两次来匹配


------解决方案--------------------
<br />
<br />
$str = '<input type="text" name="lname" />';  <br />
$str .= '<select><option value ="volvo">Volvo</option><option value ="saab">Saab</option><option value="opel">Opel</option><option value="audi">Audi</option></select>';<br />
<br />
preg_match_all("#((\<input.*\>)<br><font color='#FF8000'>------解决方案--------------------</font><br>(\<select.*\>.*\<\/select\>))#U",$str,$out);<br />
<br />
var_dump($out);<br />
<br />


这样可否?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn