Könnte man auch mit REGEXP machen
Class RegExp
''' RegExp -- use VBScript RegExp object to provide regular expressions
'
' 2004-06-03 David Phillips, rfdinc.com First version.
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, matches As Variant) 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