Finding duplicates with RegEX
scott schrieb:
That's because you need to denote the literal 'dot' as: \.
instead of an arbitrary character: .
Not directly, but you can handle it yourself, by letting a
function process (sub)matches while calling
RegExp-Replace:
MfG,
Alex
Dim src
Dim dic
Dim r
src = _
"XMTOMC320 274.4GB 512B/sect (A8188BKE)" & vbCrLf _
& "XMTOMC320 136.5GB 512B/sect (A818DNME)" & vbCrLf _
& "XSCHT6146F 68.0GB 520B/sect (3HYX5ERR0000750175VW)" & vbCrLf _
& vbCrLf _
& "XMTOMC320 274.4GB 512B/sect (A8188BKE)" & vbCrLf _
& "XMTOMC320 136.5GB 512B/sect (A818DNME)" & vbCrLf _
& "XSCHT6146F 68.0GB 520B/sect (3HYX5ERR0000750175VW)" & vbCrLf
Set dic = CreateObject("Scripting.Dictionary")
Set r = New RegExp
r.MultiLine = True
r.Global = True
r.Pattern = "^\w+ +(\d{2,3}\.\dGB) +.*\((.+)\)$"
Call r.Replace (src, GetRef("GetDriveSize"))
WSH.Echo Join(dic.Items, vbCrLf)
Sub GetDriveSize (match, s1, s2, pos, src)
Dim key
key = s1 & " " & s2
If Not dic.Exists(key) Then
dic.Add key, "Serial: " & s2 & ", Size: " & s1
End If
End Sub
|