Lotusscript 正则表达类

Lotusscript 正则表达类,Lotusscript代理调用正则表达式过滤掉代码,获取notesRichTextItem内容信息的方法

———————–使用———————————————————–

Dim re As New RegExp 
re.IgnoreCase = True ' 设置是否区分字符大小写。
re.Global = True ' 设置全局可用性。

Gst = re.Replaces (Gst, "<[^>]+>", "") '删除所有html标签

———————–Class RegExp—————————————————

Class RegExp
' RegExp -- use VBScript RegExp object to provide regular expressions
' 2004-06-03 David Phillips, rfdinc.com First version. </code>

Public matches As Variant
Public oRegExp As Variant

' VBScript RegExp properties
Public Pattern As String
Public IgnoreCase As Boolean ' default = False
Public Global As Boolean ' default = False

Sub new ()
Set oRegExp = CreateObject ("VBScript.RegExp")
End Sub

Public Function Match (source As String, pattern As String) As Boolean
' RegEx.Match -- scan source for pattern, set matches collection and return true if any
' (Can't call it Execute as that collides with LotusScript built-in function and statement.)
With oRegExp
.Pattern = pattern ' regular expression to match
.IgnoreCase = IgnoreCase
.Global = Global
Set matches = .Execute (source) ' do match
Match = (Not 0 = matches.count)
End With
End Function

Public Function Replaces (source As String, pattern As String, replacement As String) As String
' RegEx.Replaces -- scan source for pattern, if found substitute replacement, return result
' (Can't call it Replace as that collides with LotusScript built-in function.)
With oRegExp
.Pattern = pattern
.IgnoreCase = IgnoreCase
.Global = Global
Replaces = .Replace (source, replacement) ' do replace
End With
End Function

Public Function Test (source As String, pattern As String) As Boolean
' RegEx.Test -- scan source for pattern, return true if found
With oRegExp
.Pattern = pattern
.IgnoreCase = IgnoreCase
Test = .Test (source)
End With
End Function

End Class

发表评论

您的电子邮箱地址不会被公开。