您现在的位置是:首页 > 电脑技术查询 > web开发

怎么用正则表达式取<form></form>中的内容

编辑:chaxungu时间:2022-10-02 23:17:47分类:web开发

如何用正则表达式取<form></form>中的内容
求教如何用正则表达式取<form></form>中的内容
<form>
<p>a</p>
<a>b</a>
<input type="text" value="c"/>
</form>
要将三行都取出来!谢谢!


------解决方案--------------------

JScript codevar str='xxxx<form><p> a </p> <a> b </a> <input type= "text" value= "c"/></form>aaa';var re=new RegExp(/<form>([\s\S]+?)<\/form>/);if(re.test(str)) str=RegExp.$1;document.write(str);