word-wrap: break-word; margin: 5px 0px; color: rgb(0, 0, 0); font-family: " sans="" font-size:="" font-style:="" font-variant-ligatures:="" a="" href="/fw/photo.html" target="_blank" :="" font-weight:="" letter-spacing:="" line-height:="" orphans:="" text-align:="" text-indent:="" text-transform:="" white-space:="" widows:="" word-spacing:="" -webkit-text-stroke-width:="">该实例较为简单,相信大家在看了之后都能明白。
下面开始为大家介绍这个正则表达式的详细内容,<(.|\n)+?>
这个是替换所有HTML标签,非贪婪的,多行的。
如果我想替换得到所以非HTML标签,
我的代码就只能是这样,先找打HTML标签,然后将标签替换掉。
能不能直接找到非HTML标签呢。。
还有个问题就是,,截取字符串的长度。
我下面的这种方法,没有判断中文或者非中文,截取的长度总是有长有短。
不知道有没有好点的办法让截取的长度,一样长的,而不是str.Length的长度。
public static string formatString(string str, int size) { string temp = str; Regex regex = new Regex(""); temp = regex.Replace(str, ""); temp = temp.Replace("\\r\\n", ""); temp = temp.Replace(" ", ""); if (temp.Length >= size) { temp = temp.Substring(0, size - 3) + " "; } return temp; }
以上便是该实例的全部内容了,希望大家在看完这篇js正则表达式怎么替换所有HTML标签的文章之后能有所收获。
[js正则表达式怎么替换所有html标签]js正则表达式怎么替换所有HTML标签
http://m.bbyears.com/aspjiaocheng/115374.html
推荐访问: