我覺(jué)得比ijao簡(jiǎn)單,但是腦子就是轉(zhuǎn)不過(guò)彎。。。。請(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">\nnbsp;\/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 \/>\nnbsp;\/p>/ig, "/p>"); str=str.replace(/br>\nnbsp;\/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)文章!
標(biāo)簽:怒江 玉林 河北 吉林 昆明 茂名 西寧 秦皇島
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《js正則匹配table tr》,本文關(guān)鍵詞 正則,匹配,table,正則,匹配,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。