.net实现自定义UBB代码及规则的基本实现
2007-03-29 22:17
323 查看
用正则表达式来完成
Function DeLink(ByVal htmlText As String) As String '进行A标签解码
Dim hrefRegex As New Regex( _
"[urls*=s*([^""]+)s*]([sS]*?)[/url]", _
RegexOptions.IgnoreCase)
Dim output As String = ""
For Each m As Match In hrefRegex.Matches(htmlText)
htmlText = Replace(htmlText, m.Groups(0).Value, "<a href=""" & m.Groups(1).Value & """>" & m.Groups(2).Value & "</a>")
Next
Return htmlText
End Function
Function EnLink(ByVal htmlText As String) As String '进行A标签编码
Dim hrefRegex As New Regex( _
"<A[^>]*?HREFs*=s*""([^""]+)""[^>]*?>([sS]*?)</A>", _
RegexOptions.IgnoreCase)
Dim output As String = ""
For Each m As Match In hrefRegex.Matches(htmlText)
htmlText = Replace(htmlText, m.Groups(0).Value, "" & m.Groups(2).Value & "")
Next
Return htmlText
End Function
类似这样做其它的标签就可以完在基本的UBB功能
呵呵,太懒了,写字日少
Function DeLink(ByVal htmlText As String) As String '进行A标签解码
Dim hrefRegex As New Regex( _
"[urls*=s*([^""]+)s*]([sS]*?)[/url]", _
RegexOptions.IgnoreCase)
Dim output As String = ""
For Each m As Match In hrefRegex.Matches(htmlText)
htmlText = Replace(htmlText, m.Groups(0).Value, "<a href=""" & m.Groups(1).Value & """>" & m.Groups(2).Value & "</a>")
Next
Return htmlText
End Function
Function EnLink(ByVal htmlText As String) As String '进行A标签编码
Dim hrefRegex As New Regex( _
"<A[^>]*?HREFs*=s*""([^""]+)""[^>]*?>([sS]*?)</A>", _
RegexOptions.IgnoreCase)
Dim output As String = ""
For Each m As Match In hrefRegex.Matches(htmlText)
htmlText = Replace(htmlText, m.Groups(0).Value, "" & m.Groups(2).Value & "")
Next
Return htmlText
End Function
类似这样做其它的标签就可以完在基本的UBB功能
呵呵,太懒了,写字日少
相关文章推荐
- 使用rxjava实现imager loader,自定义缓存规则,
- 在.NET中实现彩色光标,动画光标和自定义光标
- .NET实现Office Excel自定义公式 广泛应用于报表与数据分析
- 在.NET中实现彩色光标,动画光标和自定义光标
- 利用反射和自定义特性实现基本数据存取操作自动获取
- 通过盘古分词自定义规则功能实现软件版本号的提取
- CLisp 8:用LISP的基本规则实现while
- .net中自定义错误页面的实现方法
- NHibernate自定义集合类型(上):基本实现方式
- 在.NET中实现彩色光标,动画光标和自定义光标
- 自定义autoCompleteTextView实现自己的匹配规则。
- atittit.表单验证的实现方式以及原理本质以及选型以及自定义兼容easyui dsl规则的表单验证
- NHibernate自定义集合类型(上):基本实现方式
- android 跑马灯效果的基本实现以及自定义实现一个界面多个跑马灯效果
- .NET 业务框架开发实战之九 Mapping属性原理和验证规则的实现策略
- 用自定义的队列实现一些基本功能
- Binary XML file line Error inflating class解决办法以及自定义view的基本实现
- Swing 实现简单的自定义不规则按钮组件
- 一起谈.NET技术,通过自定义配置实现插件式设计
- 集合的基本运算: 依据集合运算规则,实现任意给定两个集合的交、并、差、笛卡儿积运算,和第一个集合的幂集,并显示运算结果。