手机
当前位置:查字典教程网 >编程开发 >正则表达式 >用正则表达式格式化html标签的代码
用正则表达式格式化html标签的代码
摘要:复制代码代码如下:#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"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><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"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'></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>

【用正则表达式格式化html标签的代码】相关文章:

正则表达式的语法

C# 正则表达式 使用介绍

ASP.NET 中的正则表达式

Js&Vbs正则表达式替换重复的字符

php正则表达式中的非贪婪模式匹配

一个验证用户名的正则表达式

正则表达式的应用

正则表达式练习器

常用的匹配正则表达式和实例

正则表达式,提取网页中的链接地址

精品推荐
分类导航