濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > 用正則表達(dá)式格式化html標(biāo)簽的代碼

用正則表達(dá)式格式化html標(biāo)簽的代碼

熱門標(biāo)簽:廣西智能外呼系統(tǒng)多少錢 大學(xué)校門地圖標(biāo)注 荊州智能電銷機(jī)器人 銷售電銷機(jī)器人詐騙 地圖標(biāo)注與公司業(yè)務(wù)關(guān)系 外呼系統(tǒng)api對(duì)接 提高電話機(jī)器人接通率 平?jīng)龈叩碌貓D標(biāo)注商戶要收費(fèi)嗎 福建微碼電話機(jī)器人
復(fù)制代碼 代碼如下:

html>
head>
/head>
body>
style>
#x_edit{
  height:320px;
  width:540px;
  border:1px solid #666666;

  color:red;

  filter:chroma(color="#0f0f0f");
  background-color:#f0f0f0;
  font-family:verdana;
  font-size:11px;
  line-height:13px;
  margin-left:16px;
  overflow:scroll;
  border-left:none;
  scrollbar-arrow-color:#666666;
  scrollbar-base-color:#666666;
  scrollbar-darkshadow-color:#f0f0f0;
  scrollbar-face-color:#f0f0f0;
  }
/style>
span onclick="abc()">格式化/span>
div contentEditable="true" id="x_edit" style='position:relative;line-height:13px;background-color:#f0f0f0;filter:Chroma(color=#FDFEFF);width:540px;height:320px;overflow:auto;white-space: nowrap; z-index: 2;border:0px'>
P>lt;htmlgt;BR>lt;headgt;BR>lt;/headgt;BR>lt;bodygt;BR>lt;stylegt;BR>#x_edit,#x_edit1{BR>nbsp; height:320px;BR>nbsp; width:540px;BR>nbsp; border:1px solid #666666;/P>
P>nbsp; color:red;/P>
P>nbsp; filter:chroma(color="#0f0f0f");BR>nbsp; background-color:#f0f0f0;BR>nbsp; font-family:verdana;BR>nbsp; font-size:11px;BR>nbsp; line-height:13px;BR>nbsp; margin-left:16px;BR>nbsp; overflow:scroll;BR>nbsp; border-left:none;BR>nbsp; scrollbar-arrow-color:#666666;BR>nbsp; scrollbar-base-color:#666666;BR>nbsp; scrollbar-darkshadow-color:#f0f0f0;BR>nbsp; scrollbar-face-color:#f0f0f0;BR>nbsp; }BR>lt;/stylegt;BR>lt;span onclick="abc()"gt;試試獲得selection的top,然后加上div的scrollTop,然后除以行高lt;/spangt;BR>lt;span id="a" onclick="alert('a')"gt;alt;/spangt;BR>lt;span id="b" onclick="alert('b')"gt;blt;/spangt;BR>lt;span id="c" onclick="alert('c')"BR>gt;clt;/spangt;BR>lt;span id="d" onclick="alert('d')"gt;dlt;/spangt;BR>lt;span id="e" onclick="alert('e')"gt;elt;/spangt;BR>lt;span id="f" onclick="alert('f')"gt;flt;/spanBR>gt;BR>lt;span id="g"BR>nbsp;onclick="alert('g')"gt;glt;/spangt;BR>lt;textarea id="x_edit" wrap=offgt;lt;/textareagt;BR>lt;div contentEditable="true" id="x_edit1" style='position:relative;line-height:13px;background-color:#f0f0f0;filter:Chroma(color=#FDFEFF);width:540px;height:320px;overflow:auto;white-space: nowrap; z-index: 2;border:0px'gt;lt;/divgt;BR>lt;scriptgt;BR>function abc(){BR>nbsp;nbsp;nbsp; //s=x_edit1.innerText;BR>nbsp;nbsp;nbsp; var s=x_edit.value;BR>nbsp;nbsp;nbsp; s=s.replace(/\n/gi,"");BR>nbsp;nbsp;nbsp; //s=s.replace(/lt;(\w+)(.*?)[^lt;gt;]gt;/gi,"lt;"+aaa("$1$2")+"gt;");BR>nbsp;nbsp;nbsp; s=s.replace(/lt;(.*?)[^lt;gt;]gt;/gi,"lt;"+aaa("$1")+"gt;");BR>nbsp;nbsp;nbsp; s=s.replace(/\n/gi,"@");BR>nbsp;nbsp;nbsp; //var LineValue=x_edit1.innerText.split("\r")BR>nbsp;nbsp;nbsp; /*var LineValue=x_edit.value.split("\r")BR>for(var i=0;ilt;LineValue.length;i++){BR>nbsp;nbsp;nbsp; LineValue[i]=LineValue[i].replace(/(".*")/gi,"$1".replace(/lt;/gi,"\xef").replace(/gt;/gi,"\xff"))BR>nbsp;nbsp;nbsp; LineValue[i]=LineValue[i].replace(/lt;(.*[^lt;gt;])gt;/gi,"lt;"+"$1"+"gt;\r")BR>nbsp;nbsp;nbsp; LineValue[i]=LineValue[i].replace(/\r\r/gi,"\r")BR>nbsp;nbsp;nbsp; LineValue[i]=LineValue[i].replace(/(".*")/gi,"$1".replace(/\xef/gi,"lt;").replace(/\xff/gi,"gt;"))BR>}*/BR>nbsp;nbsp;nbsp; //x_edit1.innerText=LineValue.join("");BR>nbsp;nbsp;nbsp; //x_edit.value=LineValue.join("");BR>nbsp;nbsp;nbsp; x_edit.value=s;BR>nbsp;nbsp;nbsp; //x_edit1.innerText=s;BR>}BR>function aaa(str){BR>nbsp;nbsp;nbsp; str=str.replace(/\r/gi," ");BR>nbsp;nbsp;nbsp; return str;BR>}BR>lt;/scriptgt;BR>lt;/bodygt;BR>lt;/htmlgt;/P>
/div>

script>
function abc(){
    var s=x_edit.innerText;
    s=s.replace(/\/?(\w+[\s\S]*?)>/gi,function(a){return a.replace(/[\r\n]/gi,"")});
    x_edit.innerText=s;
}
/script>
/body>
/html>
您可能感興趣的文章:
  • php過(guò)濾HTML標(biāo)簽、屬性等正則表達(dá)式匯總
  • asp自動(dòng)補(bǔ)全html標(biāo)簽自動(dòng)閉合(正則表達(dá)式)
  • asp.net正則表達(dá)式刪除指定的HTML標(biāo)簽的代碼
  • Java/Js下使用正則表達(dá)式匹配嵌套Html標(biāo)簽
  • 移除HTML標(biāo)簽的正則表達(dá)式
  • 請(qǐng)教一個(gè)正則表達(dá)式,匹配所有Html標(biāo)簽外部的指定字符串
  • 使用正則表達(dá)式去除所有html標(biāo)簽只保留文字

標(biāo)簽:黔東 邯鄲 衡陽(yáng) 內(nèi)江 婁底 海南 樂山 德陽(yáng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用正則表達(dá)式格式化html標(biāo)簽的代碼》,本文關(guān)鍵詞  用,正則,表達(dá)式,格式化,;如發(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)。
  • 相關(guān)文章
  • 下面列出與本文章《用正則表達(dá)式格式化html標(biāo)簽的代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于用正則表達(dá)式格式化html標(biāo)簽的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    玉屏| 安塞县| 邵东县| 紫云| 务川| 陇南市| 宣威市| 红原县| 枣庄市| 泽普县| 高密市| 博兴县| 台州市| 和平区| 安康市| 福州市| 麻栗坡县| 资中县| 定兴县| 汪清县| 乌海市| 嘉善县| 岳西县| 黄石市| 隆德县| 天全县| 犍为县| 邵阳市| 平和县| 清流县| 肃北| 东台市| 阿荣旗| 瓦房店市| 霸州市| 石阡县| 高碑店市| 淳化县| 临漳县| 阿鲁科尔沁旗| 铜川市|