Excel 重复文字的筛选?
=重复词(A1)
=去重词(A1)
Function 重复词(a As String)
Set d = CreateObject("scripting.dictionary")
Set reg = CreateObject("vbscript.regexp")
With reg
.Global = True
.Pattern = "(.{2,}).*\1"
Do
Set sj = .Execute(a)
If sj.Count = 0 Then Exit Do
fz = sj(0).submatches(0)
d(fz) = ""
a = Replace(a, fz, "")
Loop
重复词 = Replace(Join(d.keys, "、"), ",", "")
End With
End Function
Function 去重词(a As String)
Set d = CreateObject("scripting.dictionary")
b = Split(a, ",")
For i = 0 To UBound(b)
d(b(i)) = ""
Next
去重词 = Join(d.keys, "、")
End Function