婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 正則表達式替換table表格中的樣式與空標記(保留rowspan與colspan)

正則表達式替換table表格中的樣式與空標記(保留rowspan與colspan)

熱門標簽:襄陽房產電銷機器人招商 百度地圖標注飯店位置怎么 百度地圖標注名編輯 怎么在高德地圖標注行走軌跡 個性化地圖標注在線 安徽移動外呼系統 清遠陽山400電話號碼如何申請 深圳400電話辦理那家好 施工地圖標注怎么做

完整測試代碼

script>
var str='p>';
str='table id="tblSort" cellspacing="0" helvetica="" sans="">tr id="sdf">td style="color:red" class="ok" colspan="8" height="500" rowspan="5">';
str+='td style = "color:blue" style="color:blue" colspan="8" style="color:red" rowspan="5">';
str+='td id="asdfj" class="dbclick">span id="s159015" class="p_check">a style="text-decoration: none; color: rgb(0,136,255)"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >GET/a> a style="text-decoration: none; color: rgb(0,136,255)"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >PING/a> a style="text-decoration: none; color: rgb(0,136,255)"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Trace/a> a style="text-decoration: none; color: rgb(0,136,255)"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Dig/a>/span>/td>';
str+='td class="sdf" colspan="8" style="color:red" rowspan="5">p style="color:red">jb51.net/p>/td>';
str+='td class="sdf" colspan="8" style="color:red" rowspan="5" width="100">/td>/tr>/table>';

str+='table>tr style = "color:bluefffffffffffffffffffffffffffffffffffffffffff">td style="color:green" class="ok" colspan="8" height="500" rowspan="5">';
str+='tr id="trinfo146798" class="alt">   td id="tdinfo146798" colspan="16">/td>  /tr>';
str+='td id="asdfj" class="dbclick">span id="s159015" class="p_check">a style="text-decoration: none; color: rgb(0,136,255)"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >GET/a> a style="text-decoration: none; color: rgb(0,136,255)"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >PING/a> a style="text-decoration: none; color: rgb(0,136,255)"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Trace/a> a style="text-decoration: none; color: rgb(0,136,255)"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Dig/a>/span>/td>';
str+='td class="sdf" colspan="8" style="color:red" rowspan="5">p style="color:red">jb51.net/p>/td>';
str+='td class="sdf" colspan="8" style="color:red" rowspan="5" width="100"> font color="#0f0000">122.227.189.106 [中國浙江寧波電信]/font>br />/td>/tr>/table>';

str+='p>img alt="" src="http://img.jbzj.com/file_images/article/202004/2020041112113912.png" />/p>';
str+='p>選擇安裝然后選擇全新的sql server獨立安裝/p>';
str+='p>img alt="" src="http://img.jbzj.com/file_images/article/202004/2020041112113913.png" />/p>';

console.log(str);

//去除table的寬度
str=str.replace(/table[^>]*>/ig, "table>");
str=str.replace(/table[^>]*>[\s\S]*?\/table>/gi,function(match,capture){
match=match.replace(/(style|class|id)[\s]*=[\s]*("|')[^>"']*?\2/gi,'');
match=match.replace(/\/?span[^>]*>/gi,'');
match=match.replace(/p [^>]*>|\/p>/gi,'');
match=match.replace(/font[^>]*>|\/font>/gi,'');
return match;
});

//alert(str);
console.log(str);
/script>

原來的代碼是這樣的

//普通替換
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(/table[^>]*>[\s\S]*?\/table>/gi,function(match,capture){
match=match.replace(/style[\s]*=[\s]*("|')[^>"']*?\1/gi,'');
match=match.replace(/cl\ass[\s]*=[\s]*("|')[^>"']*?\1/gi,'');
match=match.replace(/id[\s]*=[\s]*("|')[^>"']*?\1/gi,'');
match=match.replace(/font[^>]*>|\/font>/gi,'');
return match;
});
str=str.replace(/td[^>]*>/gi,function(match,capture){
match=match.replace(/style[\s]*=[\s]*("|')[^>"']*?\1/gi,'');
match=match.replace(/cl\ass[\s]*=[\s]*("|')[^>"']*?\1/gi,'');
match=match.replace(/id[\s]*=[\s]*("|')[^>"']*?\1/gi,'');
return match;
});
return str;
}

后臺修改成這樣的

str=str.replace(/table[^>]*>/ig, "table>");
str=str.replace(/table[^>]*>[\s\S]*?\/table>/gi,function(match,capture){
match=match.replace(/(style|class|id)[\s]*=[\s]*("|')[^>"']*?\2/gi,'');
match=match.replace(/\/?span[^>]*>/gi,'');
match=match.replace(/p [^>]*>|\/p>/gi,'');
match=match.replace(/font[^>]*>|\/font>/gi,'');
return match;
});

經過測試發現chrome中正常,但在ie8與ie7中有bug無法實現class與id的替換,文檔聲明!DOCTYPE html>都會影響一些結果,真是漲了見識

正好看到別的人分享的先留存一份,后續更新

用正則表達式取出table中的所有行(支持嵌套table)

此是通過csdn詢問得高人之手寫的。
謝謝gzdiablo

表達式:

tr[^>]*>(?:(?:\s|\S)*?(?=table|/tr>)(?(table)table[^>]*>(?:\s|\S)*?(?:/table>|(?:(?:table[^>]*>(?:\s|\S)*?/table>(?:\s|\S)*?)*?/table>))(?:\s|\S)*?|))*/tr>

一條表達式就可以獲取你想要的
寫得好辛苦
測試:

table width="300" border="1" cellspacing="0" cellpadding="0">
 tr>
 td>nbsp;/td>
 td>table width="100%" border="1" cellspacing="0" cellpadding="0">
  tr>
  td>nbsp;/td>
  /tr>

 /table>
  table width="100%" border="1" cellspacing="0" cellpadding="0">
  tr>
   td>nbsp;/td>
  /tr>
  /table>/td>
 td>nbsp;/td>
 /tr>
 tr>
 td>nbsp;/td>
 td>nbsp;/td>
 td>table width="100%" border="1" cellspacing="0" cellpadding="0">

  tr>
  td>nbsp;/td>
  /tr>
 /table>/td>
 /tr>
 tr>
 td>table width="100%" border="1" cellspacing="0" cellpadding="0">
  tr>
  td>nbsp;/td>
  /tr>

 /table>/td>
 td>nbsp;/td>
 td>nbsp;/td>
 /tr>
/table>

-------------------獲取3個match

============================================match1
  tr>
    td>nbsp;/td>
    td>table width="100%" border="1" cellspacing="0" cellpadding="0">
      tr>
        td>nbsp;/td>
        /tr>

    /table>
      table width="100%" border="1" cellspacing="0" cellpadding="0">
        tr>
          td>nbsp;/td>
        /tr>
      /table>/td>
    td>nbsp;/td>
  /tr>
==============================================match2
  tr>
    td>nbsp;/td>
    td>nbsp;/td>
    td>table width="100%" border="1" cellspacing="0" cellpadding="0">

      tr>
        td>nbsp;/td>
        /tr>
    /table>/td>
  /tr>
==============================================match3
  tr>
    td>table width="100%" border="1" cellspacing="0" cellpadding="0">
      tr>
        td>nbsp;/td>
        /tr>

    /table>/td>
    td>nbsp;/td>
    td>nbsp;/td>
  /tr>

正則表達式匹配html標簽table

首先,要匹配任意內容“.”是不行的,因為不匹配“\n”,取不到想要的內容,所以有了如下表達式:
    [\s\S]*

當然,你也可以用 “[\d\D]*”、“[\w\W]*” 來表示。

現在我們來匹配一個html標簽,匹配table如下:

table.*?>[\s\S]*\/table>

table.*?>[\s\S]*?\/table>

以上兩個表達式,一個加了"?"和一個卻不加“?”,那么這有什么區別呢?
我們知道“?”在正則表達式里是一個通配符:匹配前面的子表達式零次或一次,或指明一個非貪婪限定符。

在這里,通過測試,我們得出這樣的結論:在不加“?”的情況下,在匹配下面一段內容的時候:

table>這是第一個table/table>
我不是table里的內容
table>這是第二個table/table>
我也不是table里的內容
table>這是第三個table/table>

會把以table>開始,/table>結束的內容都匹配出來

加了“?”之后,只匹配第n個匹配的內容

完整測試代碼腳本之家小編提供

script>
var str='table>這是第一個table/table>';
str+='我不是table里的內容';
str+='table>這是第二個table/table>';
str+='我也不是table里的內容';
str+='table>這是第三個table/table>';

var reg1 = /table.*?>[\s\S]*\/table>/gi;
var res1 = str.match(reg1);
console.log(res1) 
var reg2 = /table.*?>[\s\S]*?\/table>/gi;
var res2 = str.match(reg2);
console.log(res2) 
/script>

效果圖

以上就是正則表達式替換table表格中的樣式與空標記(保留rowspan與colspan)的詳細內容,更多關于正則表達式替換table表格的資料請關注腳本之家其它相關文章!

標簽:南昌 欽州 延邊 臨夏 中衛 黑河 阜陽 駐馬店

巨人網絡通訊聲明:本文標題《正則表達式替換table表格中的樣式與空標記(保留rowspan與colspan)》,本文關鍵詞  正則,表達式,替換,table,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《正則表達式替換table表格中的樣式與空標記(保留rowspan與colspan)》相關的同類信息!
  • 本頁收集關于正則表達式替換table表格中的樣式與空標記(保留rowspan與colspan)的相關信息資訊供網民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    亚洲五码中文字幕| 欧美日免费三级在线| 欧美本精品男人aⅴ天堂| 国产精品99久久久久久有的能看| 国产精品日日摸夜夜摸av| 欧美午夜精品电影| 国产酒店精品激情| 亚洲成人精品影院| 久久免费午夜影院| 欧美日韩激情一区| 成人app网站| 久久99久久99小草精品免视看| 国产精品女主播av| 日韩午夜av电影| 在线精品亚洲一区二区不卡| 国产成人在线网站| 蜜臀av性久久久久蜜臀av麻豆 | 91精品久久久久久久99蜜桃 | 欧美电视剧免费观看| 91丨国产丨九色丨pron| 91麻豆精品国产91久久久更新时间| 国产美女av一区二区三区| 怡红院av一区二区三区| 国产欧美精品在线观看| 欧美大片顶级少妇| 久久99久久99小草精品免视看| 亚洲欧美电影院| 欧美精品一区二区三区蜜臀| 91精品国产91久久久久久最新毛片| 色丁香久综合在线久综合在线观看| 奇米一区二区三区av| 一区二区三区影院| 亚洲免费伊人电影| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产精品美女久久久久aⅴ | 亚洲欧洲日本在线| 国产精品人成在线观看免费| 国产日韩欧美精品在线| 久久精品视频一区| 中文字幕av一区二区三区| 欧美tickle裸体挠脚心vk| 久久人人超碰精品| 中文字幕在线一区二区三区| 亚洲美女偷拍久久| 亚洲一区自拍偷拍| 亚洲国产综合在线| 美女网站色91| 国产综合色在线| www.日本不卡| 欧美日韩精品一区二区三区蜜桃| 777亚洲妇女| 久久久美女毛片| 国产欧美日韩久久| 最新欧美精品一区二区三区| 亚洲综合图片区| 一区二区三区在线视频免费| 日韩精品久久久久久| 国产激情一区二区三区| 色婷婷av久久久久久久| 91精品国产综合久久精品| 欧美国产成人精品| 亚洲va中文字幕| 国产乱码字幕精品高清av| 一本大道av伊人久久综合| 91福利资源站| 精品少妇一区二区| 亚洲男人的天堂一区二区| 青青草97国产精品免费观看 | 亚洲成人免费观看| 国产一区二区在线视频| 色妞www精品视频| 91精品国产乱码久久蜜臀| 国产精品免费视频网站| 日本伊人精品一区二区三区观看方式| 精品中文字幕一区二区| 日本高清成人免费播放| 日韩欧美国产三级| 亚洲黄色性网站| 国产激情视频一区二区三区欧美 | 久久色在线视频| 亚洲综合男人的天堂| 高清shemale亚洲人妖| 日韩欧美不卡在线观看视频| 亚洲午夜影视影院在线观看| 本田岬高潮一区二区三区| 精品国产一区二区三区四区四| 亚洲视频免费观看| 国产91精品免费| 久久久久久一二三区| 蜜桃视频第一区免费观看| 欧美日韩国产综合视频在线观看| 国产精品久久午夜夜伦鲁鲁| 蜜桃视频免费观看一区| 欧美情侣在线播放| 亚洲 欧美综合在线网络| 91丨九色丨黑人外教| 国产欧美日韩久久| 久久99精品国产麻豆不卡| 69久久99精品久久久久婷婷| 亚洲美女精品一区| 国产91对白在线观看九色| 国产日产欧美一区二区视频| 国产一区二区免费看| 久久久久久久网| 国产精品亚洲一区二区三区妖精 | 3atv一区二区三区| 亚洲高清不卡在线观看| 在线观看成人免费视频| 一区二区高清视频在线观看| 色综合天天综合| 一区二区三区欧美久久| 成人永久免费视频| 精品盗摄一区二区三区| 国内精品嫩模私拍在线| 欧美一区二区三区四区高清| 亚洲国产成人精品视频| 欧美在线不卡视频| 婷婷开心久久网| 日韩欧美色综合网站| 精品一区二区三区免费| 26uuu精品一区二区 | 色婷婷精品大视频在线蜜桃视频 | 97精品久久久午夜一区二区三区| 中文子幕无线码一区tr| 成人国产一区二区三区精品| 欧美激情综合网| 91女人视频在线观看| 亚洲成av人片在线观看无码| 欧美一区二区三区免费大片| 麻豆精品在线播放| 中文av一区二区| 色综合视频一区二区三区高清| 亚洲成人在线观看视频| 精品久久久久一区| 青青草97国产精品免费观看无弹窗版| 精品福利一二区| 国产成人日日夜夜| 久久精品视频一区二区三区| 国产91精品入口| 中文字幕亚洲综合久久菠萝蜜| 欧美午夜精品久久久久久孕妇 | 91最新地址在线播放| 亚洲国产精品一区二区久久恐怖片| 日韩一区二区三区视频在线| 成人永久看片免费视频天堂| 午夜电影网一区| 2023国产精品视频| 99免费精品视频| 亚洲精品老司机| 欧美日韩一区久久| 国产精品一区二区免费不卡| 亚洲人吸女人奶水| 欧美一区二区久久久| 国产成人精品三级| 国产日本欧美一区二区| 欧美老人xxxx18| 韩国毛片一区二区三区| 亚洲欧洲日本在线| 日韩欧美综合在线| 91麻豆.com| 国产精品自在在线| 一区二区在线观看免费视频播放| 国产三级欧美三级| 日韩欧美电影一区| 欧美精品久久99久久在免费线 | 色一情一乱一乱一91av| 激情综合色播五月| 日韩国产在线一| 亚洲超碰精品一区二区| 亚洲精品午夜久久久| 26uuu国产电影一区二区| 91成人在线精品| 99国产欧美另类久久久精品| 国产传媒欧美日韩成人| 极品美女销魂一区二区三区免费| 亚洲资源中文字幕| 国产精品免费免费| 欧美一区二区三区在| 色婷婷国产精品综合在线观看| 青青草国产成人99久久| 亚洲国产精品一区二区www| 中文字幕乱码一区二区免费| 精品国产免费人成电影在线观看四季 | 日本国产一区二区| 91麻豆免费在线观看| 99综合电影在线视频| 成人app网站| 91香蕉国产在线观看软件| 91丝袜美女网| 成人午夜视频在线观看| 成人视屏免费看| 成人av在线播放网址| 国产精品一级二级三级| 国产成人免费在线视频| 欧美a一区二区| 蜜臀av性久久久久av蜜臀妖精| 日日夜夜免费精品| 美女爽到高潮91| 狠狠色丁香久久婷婷综| 国产精品伊人色|