用正则表达式格式化html标签的代码_正则表达式教程-查字典教程网
用正则表达式格式化html标签的代码
用正则表达式格式化html标签的代码
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:#x_edit{height:320px;width:540px;border:1pxsolid#666666;color...

复制代码 代码如下:

<html>

<head>

</head>

<body>

<style>

#x_edit{

height:320px;

width:540px;

border:1pxsolid#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>

<spanonclick="abc()">格式化</span>

<divcontentEditable="true"id="x_edit">

<P><html><BR><head><BR></head><BR><body><BR><style><BR>#x_edit,#x_edit1{<BR>height:320px;<BR>width:540px;<BR>border:1pxsolid#666666;</P>

<P>color:red;</P>

<P>filter:chroma(color="#0f0f0f");<BR>background-color:#f0f0f0;<BR>font-family:verdana;<BR>font-size:11px;<BR>line-height:13px;<BR>margin-left:16px;<BR>overflow:scroll;<BR>border-left:none;<BR>scrollbar-arrow-color:#666666;<BR>scrollbar-base-color:#666666;<BR>scrollbar-darkshadow-color:#f0f0f0;<BR>scrollbar-face-color:#f0f0f0;<BR>}<BR></style><BR><spanonclick="abc()">试试获得selection的top,然后加上div的scrollTop,然后除以行高</span><BR><spanid="a"onclick="alert('a')">a</span><BR><spanid="b"onclick="alert('b')">b</span><BR><spanid="c"onclick="alert('c')"<BR>>c</span><BR><spanid="d"onclick="alert('d')">d</span><BR><spanid="e"onclick="alert('e')">e</span><BR><spanid="f"onclick="alert('f')">f</span<BR>><BR><spanid="g"<BR>onclick="alert('g')">g</span><BR><textareaid="x_edit"wrap=off></textarea><BR><divcontentEditable="true"id="x_edit1"></div><BR><script><BR>functionabc(){<BR>//s=x_edit1.innerText;<BR>vars=x_edit.value;<BR>s=s.replace(/n/gi,"");<BR>//s=s.replace(/<(w+)(.*?)[^<>]>/gi,"<"+aaa("$1$2")+">");<BR>s=s.replace(/<(.*?)[^<>]>/gi,"<"+aaa("$1")+">");<BR>s=s.replace(/n/gi,"@");<BR>//varLineValue=x_edit1.innerText.split("r")<BR>/*varLineValue=x_edit.value.split("r")<BR>for(vari=0;i<LineValue.length;i++){<BR>LineValue[i]=LineValue[i].replace(/(".*")/gi,"$1".replace(/</gi,"xef").replace(/>/gi,"xff"))<BR>LineValue[i]=LineValue[i].replace(/<(.*[^<>])>/gi,"<"+"$1"+">r")<BR>LineValue[i]=LineValue[i].replace(/rr/gi,"r")<BR>LineValue[i]=LineValue[i].replace(/(".*")/gi,"$1".replace(/xef/gi,"<").replace(/xff/gi,">"))<BR>}*/<BR>//x_edit1.innerText=LineValue.join("");<BR>//x_edit.value=LineValue.join("");<BR>x_edit.value=s;<BR>//x_edit1.innerText=s;<BR>}<BR>functionaaa(str){<BR>str=str.replace(/r/gi,"");<BR>returnstr;<BR>}<BR></script><BR></body><BR></html></P>

</div>

<script>

functionabc(){

vars=x_edit.innerText;

s=s.replace(/</?(w+[sS]*?)>/gi,function(a){returna.replace(/[rn]/gi,"")});

x_edit.innerText=s;

}

</script>

</body>

</html>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新正则表达式学习
    热门正则表达式学习
    编程开发子分类