亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

js正則匹配table tr

 更新時(shí)間:2020年04月02日 00:48:40   投稿:mdxy-dxy  
這篇文章主要介紹了js正則匹配table tr,需要的朋友可以參考下

我覺得比ijao簡單,但是腦子就是轉(zhuǎn)不過彎。。。。請正則高手看看阿。

<textarea id="txt"> 
<table border=1 width="20%">           
        <tr><th>title</th><th>title2</th></tr> 
           <tr rs="{id:\'section006\'}"><td>data1</td><td>data2      </td> 
           </tr> 
           <tr ><td>data1</td><td>data2</td></tr> 
</table> 
</textarea> 

<script> 
var str = document.getElementById('txt').value; 
alert(str); 
</script>

/<tr[^>]*>[\s\S]*?<\/tr>/gi,

分享一個(gè)函數(shù)

//普通替換
function doRepNormal(s){
var str=s.replace(/<p><br type="_moz">\s*?<\/p>/ig,"");
str=str.replace(/<p>\s*?<br type="_moz">\s*?<\/p>/ig, "");
str=str.replace(/<p>(\s|\&nbsp\;| | |\xc2\xa0)*?<\/p>/ig, "");
str=str.replace(/<p>\s*?<\/p>/ig,"");
str=str.replace(/<p>&nbsp;<\/p>/ig,"");
str=str.replace(/<br type="_moz">\n&nbsp;<\/p>/ig, "</p>");
str=str.replace(/<br type="_moz">\s*?<\/p>/ig, "</p>");
str=str.replace(/<br\s*?\/?>\s*?<\/p>/ig, "</p>");
str=str.replace(/<br \/>\n&nbsp;<\/p>/ig, "</p>");
str=str.replace(/<br>\n&nbsp;<\/p>/ig, "</p>");
//表格替換 
str=str.replace(/<table[^<>]*>/ig, "<table>");
str=str.replace(/<thead[^<>]*>/ig, "<thead>");
str=str.replace(/<tbody[^<>]*>/ig, "<tbody>");
str=str.replace(/<tfoot[^<>]*>/ig, "<tfoot>");
str=str.replace(/<tr[^<>]*>/ig, "<tr>");
str=str.replace(/<th [^<>]*>/ig, "<th>");
str=str.replace(/<td[^<>]*>/ig, "<td>");
str=str.replace(/<th>\s*?<p>/ig, "<th>");
str=str.replace(/<\/p>\s*?<\/th>/ig, "</th>");
str=str.replace(/<td[^<>]*>\s*?<p>/ig, "<td>");
str=str.replace(/<td>\s*?<p>/ig, "<td>");
str=str.replace(/<\/p>\s*?<\/td>/ig, "</td>");
return str;
}

以上就是js正則匹配table tr的詳細(xì)內(nèi)容,更多關(guān)于js正則table的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論