Option
Explicit
Sub
TestString()
Dim
regex
As
RegExp, oMatches
As
MatchCollection, oMatch
As
Match, oSubMatch
As
Match
Dim
arrDate()
As
String
, x
As
Integer
Dim
strDate
As
String
Const
C_Test
As
String
=
"Datum 12.12.2012 und Datum 31.10.2018 und 01.01.2000 zuletzt"
Set
regex = CreateObject(
"VBScript.RegExp"
)
With
regex
.Pattern =
"([0-2][0-9]|(3)[0-1])[-|.](((0)[0-9])|((1)[0-2]))[-|.]\d{4}"
.Global =
True
End
With
If
regex.Test(C_Test)
Then
Set
oMatches = regex.Execute(C_Test)
For
Each
oMatch
In
oMatches
ReDim
Preserve
arrDate(x)
arrDate(x) = oMatch.Value
x = x + 1
Next
oMatch
End
If
strDate = C_Test
For
x = LBound(arrDate)
To
UBound(arrDate)
strDate = Replace(strDate, arrDate(x), arrDate(x) & vbLf)
Next
x
MsgBox strDate
End
Sub