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

求一表达式去除特定内容.该怎么处理

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

求一表达式去除特定内容.
<form name= "searchForm " method= "post " action= "JavaScript:checkInput() ">
内容长度不定
</form>


其中 <form name= "searchForm " method= "post " action= "JavaScript:checkInput() "> 这格式固定.

把整个form的内容全部去除了.

------解决方案--------------------
<script>
var str = 'aaa <form name= "searchForm " method= "post " action= "JavaScript:checkInput() "> 内 <asiwasoa> <html> <td> /edwdsa定 </form> cccc ';
str=str.replace(/ <form name=\ "searchForm\ " method=\ "post\ " action=\ "JavaScript:checkInput\(\)\ "[\s\S]*? <\/form> /gi, " ");
alert(str);
</script>

------解决方案--------------------
<form name=\ "searchForm\ " method=\ "post\ " action=\ "JavaScript:checkInput\(\)\ "> [\s|\S]*? <\/form>