asp自动补全html标签自动闭合(正则表达式)

来源:asp之家 时间:2013-06-01 20:01:59 

代码如下:


Function closeHTML(strContent)
Dim arrTags, i, OpenPos, ClosePos, re, strMatchs, j, Match
Set re = New RegExp
re.IgnoreCase = True
re.Global = True
arrTags = Array("p", "div", "span", "table", "ul", "font", "b", "u", "i", "h1", "h2", "h3", "h4", "h5", "h6")
For i = 0 To UBound(arrTags)
OpenPos = 0
ClosePos = 0


re.Pattern = "\<" + arrTags(i) + "( [^\<\>]+|)\>"
Set strMatchs = re.Execute(strContent)
For Each Match in strMatchs
OpenPos = OpenPos + 1
Next
re.Pattern = "\</" + arrTags(i) + "\>"
Set strMatchs = re.Execute(strContent)
For Each Match in strMatchs
ClosePos = ClosePos + 1
Next
For j = 1 To OpenPos - ClosePos
strContent = strContent + "</" + arrTags(i) + ">"
Next
Next
closeHTML = strContent
End Function

标签:自动闭合,自动补全
0
投稿

猜你喜欢

  • 详解pytorch的多GPU训练的两种方式

    2023-08-04 09:58:29
  • 用Python写一个简易版弹球游戏

    2022-02-14 04:03:55
  • Python3+RIDE+RobotFramework自动化测试框架搭建过程详解

    2022-04-15 00:01:01
  • vue-cli创建项目时由esLint校验导致报错或警告的问题及解决

    2024-05-29 22:23:42
  • W3C Group的JavaScript1.8新特性介绍

    2009-07-24 12:31:00
  • MSSQL经典语句

    2024-01-22 02:59:12
  • Javascript技术栈中的四种依赖注入小结

    2024-04-18 10:54:08
  • 基于pako.js实现gzip的压缩和解压功能示例

    2024-04-22 22:14:41
  • Vue.directive 自定义指令的问题小结

    2024-05-09 10:43:29
  • 基于python模拟TCP3次握手连接及发送数据

    2022-04-02 02:40:33
  • python实现登录与注册系统

    2022-04-26 02:32:38
  • Pytorch实现List Tensor转Tensor,reshape拼接等操作

    2021-06-06 19:58:51
  • JS在IE和FireFox之间常用函数的区别小结

    2024-04-16 09:54:54
  • php异步:在php中使用fsockopen curl实现类似异步处理的功能方法

    2023-07-21 14:48:58
  • 解决python3 HTMLTestRunner测试报告中文乱码的问题

    2021-10-19 04:34:06
  • 将pytorch的网络等转移到cuda

    2023-08-10 08:33:46
  • Python 模块EasyGui详细介绍

    2022-04-27 22:55:39
  • PYcharm 激活方法(推荐)

    2022-07-27 01:51:21
  • MySQL 存储过程中执行动态SQL语句的方法

    2024-01-12 21:22:22
  • windows系统下Python环境的搭建(Aptana Studio)

    2021-03-16 20:40:37
  • asp之家 网络编程 m.aspxhome.com