最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js正則匹配table tr

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

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

<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的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論

湟源县| 东兴市| 咸宁市| 台中县| 托克托县| 韶关市| 壤塘县| 孝感市| 太仆寺旗| 朝阳区| 昌乐县| 鸡泽县| 招远市| 金寨县| 泸溪县| 称多县| 多伦县| 颍上县| 马鞍山市| 南乐县| 呼伦贝尔市| 灵寿县| 凤城市| 望都县| 广平县| 平山县| 佛学| 手机| 高雄市| 县级市| 清徐县| 贵定县| 平昌县| 兴城市| 巩义市| 邯郸县| 莒南县| 黄陵县| 鄄城县| 德钦县| 喀什市|