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

主頁 > 知識庫 > js處理網頁編輯器轉義、去除轉義、去除HTML標簽的正則

js處理網頁編輯器轉義、去除轉義、去除HTML標簽的正則

熱門標簽:外呼系統無呼出路由是什么原因 梅縣地圖標注 400電話辦理電話辦理 ai電話機器人搭建 貴港公司如何申請400電話 地圖標注教學點 甘肅醫療外呼系統排名 呼叫系統外呼只能兩次 西藏智能外呼系統代理商

富文本編輯器生成的HTML標簽,進行轉義,然后寫入數據庫,防止腳本注入:

function htmlEncode(value){
  return $('div/>').text(value).html();
}

1、從數據庫拿出的轉義后的HTML標簽內容,先得去除轉義,然后再去除HTML標簽,是生成縮略文字。

/*移除HTML標簽代碼*/
 function removeHTMLTag(str) {
   str = str.replace(/\/?[^>]*>/g,''); //去除HTML tag
   str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
   //str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
   str=str.replace(/ /ig,'');//去掉 
   return str;
 }
 //轉意符換成普通字符
 function escape2Html(str) { 
  var arrEntities={'lt':'','gt':'>','nbsp':' ','amp':'','quot':'"'}; 
  return str.replace(/(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];}); 
 } 

如果是文章詳情頁的話,直接去除轉義就可以顯示在頁面了:

 //轉意符換成普通字符
 function escape2Html(str) { 
  var arrEntities={'lt':'','gt':'>','nbsp':' ','amp':'','quot':'"'}; 
  return str.replace(/(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];}); 
 } 

2、JS正則過濾(去除)富文本編輯器中的FONT-SIZE標簽

var test=test.replace(/font-size:\w+;?/g,'');

3、js處理去掉富文本編輯的html,樣式,只顯示純文字內容,以供列表頁使用

script type="text/javascript">
var description = 'p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.1pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> b>span lang="EN-US" style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">1./span>/b>b>span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">國際保險經紀行業收入分析span lang="EN-US">o:p>/o:p>/span>/span>/b>/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> span lang="EN-US" style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">2010/span>span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">年全球保險經紀行業市場規模為span lang="EN-US">437.56/span>億美元,span lang="EN-US">2015/span>年增長至span lang="EN-US">581.3/span>億美元。span lang="EN-US">o:p>/o:p>/span>/span>/p> p align="center" style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt; margin-left:0cm;text-align:center;mso-pagination:widow-orphan"> span lang="EN-US" style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">2010-2015/span>span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">年國際保險經紀行業市場規模:億美元/span>/p> p style="margin: 19.5pt 0cm; text-indent: 24.1pt; text-align: center;"> img alt="" src="/baoxian/userfiles/1/images/back/news/2018/01/11.png" style="width: 493px; height: 296px;" />/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.1pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> b>span lang="EN-US" style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">2./span>/b>b>span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">國際保險經紀行業并購分析span lang="EN-US">o:p>/o:p>/span>/span>/b>/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">保險經紀公司并購較為頻繁,span lang="EN-US">2011/span>年并購數量為span lang="EN-US">351/span>件,且呈現增長趨勢。一股保險行業的并購風潮正席卷全球各個市場。如意大利投資集團span lang="EN-US">Exor/span>收購再保險公司span lang="EN-US">PartnerRe/span>、韜睿惠悅與韋萊集團、韋萊與法國保險經紀公司span lang="EN-US">GrasSavoye/span>、瑞士保險集團span lang="EN-US">ACE/span>并購span lang="EN-US">Chubb/span>以及美國保險公司span lang="EN-US">Anthem/span>收購span lang="EN-US">Cigna/span>。而這些不過是近年來保險業并購案清單的一小部分。span lang="EN-US">o:p>/o:p>/span>/span>/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">然而,在熱鬧喧囂的并購消息背后卻是嚴酷的現實。波士頓咨詢(span lang="EN-US">BCG/span>)對span lang="EN-US">1990/span>~span lang="EN-US">2014/span>年間span lang="EN-US">778/span>件涉及保險業的并購案進行了分析,對并購后一年內的股東總回報進行了追蹤,最終發現只有span lang="EN-US">51%/span>的并購能實際創造價值,而span lang="EN-US">49%/span>的并購案則摧毀了公司的價值。近半數并購案失敗可歸咎為三大原因:并購準備和執行、并購后整合以及并購時機。span lang="EN-US">o:p>/o:p>/span>/span>/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.1pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> b>span lang="EN-US" style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">3./span>/b>b>span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">保險業持續大整合span lang="EN-US">o:p>/o:p>/span>/span>/b>/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">未來span lang="EN-US">5/span>年,多個宏觀層面的因素將繼續推動保險業進行整合。首先是監管繼續收緊,尤其是對資本充足率的要求將繼續提升,無論是獨立保險商還是綜合集團都將感到更大的資金壓力。利率和投資回報將繼續保持較低水平(至少在成熟市場),使傳統的壽險業務盈利能力受到限制。span lang="EN-US">o:p>/o:p>/span>/span>/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">此外,新興競爭對手的威脅也不可小覷,甚至大型連鎖超市和電信公司都有可能顛覆保險行業的價值鏈。這些企業不但擁有價值連城的消費者數據,而且擁有與客戶之間的“最后一公里”連接。在新的運營模式下,傳統保險企業難以掌控整條價值鏈,且容易成為新型商業模式的顛覆目標,例如一些網絡聚合搜索產品能夠為消費者提供價格透明的產品對比。span lang="EN-US">o:p>/o:p>/span>/span>/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">資金充裕的大型保險公司可以利用投資抵御創新帶來的威脅,而那些只聚焦于內部運營,對外部變化視而不見的中型企業將面臨更激烈的競爭。對于保險公司來說,了解消費者的行為和需求是至關重要的能力,然而建設必需的大數據技術、文化和團隊帶來的成本巨大,讓規模較小的保險公司難以承受。對于保險企業來說,有機成長的機會非常有限。成熟市場已經進入到整合周期內,盡管新興市場存在著發展機遇,但市場環境非常復雜。要在新市場形成規模效應,并購顯然仍是各大保險企業的明智之選。span lang="EN-US">o:p>/o:p>/span>/span>/p> p align="center" style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt; margin-left:0cm;text-align:center;mso-pagination:widow-orphan"> span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">世界排名前十保險經紀公司國際業務占比span lang="EN-US">o:p>/o:p>/span>/span>/p> p align="center" style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt; margin-left:0cm;text-align:center;mso-pagination:widow-orphan"> img alt="" src="/baoxian/userfiles/1/images/back/news/2018/01/12.png" style="width: 554px; height: 289px;" />/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.1pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> b>span lang="EN-US" style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">4./span>/b>b>span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">國際保險經紀行業利潤水平span lang="EN-US">o:p>/o:p>/span>/span>/b>/p> p style="margin-top:19.5pt;margin-right:0cm;margin-bottom:19.5pt;margin-left: 0cm;text-indent:24.0pt;mso-char-indent-count:2.0;mso-pagination:widow-orphan"> span style="font-family:宋體;mso-bidi-font-family:宋體;color:#252525">目前,span lang="EN-US">2015/span>年全球保險經紀行業收入達span lang="EN-US">581.3/span>億美元,國際保險經紀行業利潤水平維持在span lang="EN-US">10~25%/span>之間。span lang="EN-US">o:p>/o:p>/span>/span>/p>';
description = description.replace(/(\n)/g, ""); 
description = description.replace(/(\t)/g, ""); 
description = description.replace(/(\r)/g, ""); 
description = description.replace(/\/?[^>]*>/g, ""); 
description = description.replace(/\s*/g, "");
console.log(description) 
/script>

4、jQuery JavaScript正則表達式與\n代替BR>

Lee TaylorTeneff給出了該問題的處理方式:

var str = document.getElementById('mydiv').innerHTML;
document.getElementById('mytextarea').innerHTML = str.replace(/br\s*[\/]?>/gi, "\n");

or using jQuery:

var str = $("#mydiv").html();
var regex = /br\s*[\/]?>/gi;
$("#mydiv").html(str.replace(regex, "\n"));

5、要去除html標簽,圖片,換行,回車等

description = description.replace(/(\n)/g, "");
description = description.replace(/(\t)/g, "");
description = description.replace(/(\r)/g, "");
description = description.replace(/\/?[^>]*>/g, "");
description = description.replace(/\s*/g, "");

6、腳本之家小編寫的一個替換fackeditor中的多余br與空行的

//加強替換主要是考慮多個br的問題
function doRepAdvance(s){
var str=s.replace(/p>br type="_moz">\/p>/ig,"");
str=str.replace(/br type="_moz">\nnbsp;\/p>/ig, "/p>");
str=str.replace(/br type="_moz">\n\/p>/ig, "/p>");
str=str.replace(/br type="_moz">\n\r\/p>/ig, "/p>");
str=str.replace(/br type="_moz">\/p>/ig,"/p>");
str=str.replace(/br \/>\nnbsp;\/p>/ig, "/p>");
str=str.replace(/br>\nnbsp;\/p>/ig, "/p>");
str=str.replace(/br \/>\n\/p>/ig, "/p>");
str=str.replace(/br \/>\n\r\/p>/ig, "/p>");
str=str.replace(/(br>\n){1,}\/p>/ig,"/p>");
str=str.replace(/(br>){1,}\/p>/ig,"/p>");
str=str.replace(/br>\n\/p>/ig, "/p>");
str=str.replace(/br>\/p>/ig,"/p>");
str=str.replace(/p> \/p>/ig,"");
str=str.replace(/p>nbsp;\/p>/ig,"");
str=str.replace(/p> \/p>/ig,"");
str=str.replace(/p>\/p>/ig,"");
return str;
}

到此這篇關于js處理富文本編輯器轉義、去除轉義、去除HTML標簽的正則的文章就介紹到這了,更多相關編輯器轉義、去除轉義、去除HTML標簽內容請搜素腳本之家以前的文章或下面相關文章,希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • JS及JQuery對Html內容編碼,Html轉義
  • JS轉換HTML轉義符的方法
  • JS實現HTML標簽轉義及反轉義
  • javascript對HTML字符轉義與反轉義
  • 在JavaScript中對HTML進行反轉義詳解
  • 對字符串進行HTML編碼和解碼的JavaScript函數
  • Javascript String對象擴展HTML編碼和解碼的方法
  • JavaScript中最簡潔的編碼html字符串的方法
  • JS Html轉義和反轉義(html編碼和解碼)的實現與使用方法總結

標簽:湖州 哈密 大興安嶺 海口 泰安 涼山 本溪 常州

巨人網絡通訊聲明:本文標題《js處理網頁編輯器轉義、去除轉義、去除HTML標簽的正則》,本文關鍵詞  處理,網頁,編輯器,轉義,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《js處理網頁編輯器轉義、去除轉義、去除HTML標簽的正則》相關的同類信息!
  • 本頁收集關于js處理網頁編輯器轉義、去除轉義、去除HTML標簽的正則的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 海丰县| 博湖县| 定日县| 荔浦县| 孝昌县| 奉化市| 巴里| 大余县| 红河县| 水富县| 浪卡子县| 大方县| 通榆县| 维西| 密山市| 青川县| 得荣县| 宜章县| 正阳县| 阳信县| 建德市| 海门市| 双城市| 喀喇沁旗| 苏尼特左旗| 游戏| 麻阳| 芮城县| 南部县| 登封市| 咸阳市| 婺源县| 上饶县| 凭祥市| 三江| 云霄县| 肇东市| 岳西县| 桦川县| 昆明市| 郑州市|