Функцию в модуль
Public Function regMatch(ByVal inStr2 As String, ByVal patternStr As String, Optional ByVal idx As Integer = -1) As String
Dim regEx As New RegExp
Dim regMatches As Object
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = patternStr
If .Test(inStr2) Then
If (idx >= 0) Then
If .Execute(inStr2)(0).SubMatches.Count() > idx Then
regMatch = .Execute(inStr2)(0).SubMatches(idx)
Else
regMatch = ""
End If
Else
regMatch = .Execute(inStr2)(0)
End If
Else
regMatch = ""
End If
End With
End Function
Пример формулы в ячейке
=regMatch(H3;"(\(|\{)\s*([0-9A-Z]{8}\s*\-\s*[0-9A-Z]{8})\s*(\}|\))";1)
Последний параметр необязательный
=regMatch(H4;"(\(|\{)\s*([0-9A-Z]{8}\s*\-\s*[0-9A-Z]{8})\s*(\}|\))")