With New RegExp
.Pattern = "\[(.+?)\].*"
Debug.Print .Replace("[20524.00-0-КСУ(Ц)-0-ГП л. 002 Ред. B1][146Y.pdf] #00 ", "$1")
End With
Function ClearName(ByVal strText As String, ByVal strPattern As String) As String
Dim RegExp As Object
Set RegExp = CreateObject("vbscript.regexp")
With RegExp
.Pattern = strPattern
.Global = True
ClearName = .Replace(Trim(strText), "")
End With
End Function
Sub Test()
strText = "[20524.00-0-КСУ(Ц)-0-ГП л. 002 Ред. B1][146Y.pdf] #00.pdf "
strPattern = "(\[\S{4})\.(\S{3}\])|(\s#\d{2})|[\[\]]"
MsgBox ClearName(strText, strPattern)
End Sub
Сейчас этот форум просматривают: Yandex-бот и гости: 49