AlexanderBB
Well-known Member
- Joined
- Jul 1, 2009
- Messages
- 2,099
- Office Version
- 2019
- 2010
- Platform
- Windows
This extracts the bracketed part of s
Can it also remove the opening/closing brackets at the same time?
VBA Code:
Function TestBracket(s) As String
Dim RE As Object, REMatches As Object
Set RE = CreateObject("vbscript.regexp")
RE.Pattern = "\(.*?\)"
If (RE.test(s) = True) Then
Set REMatches = RE.Execute(s)
TestBracket = REMatches(0)
End If
Set REMatches = Nothing
Set RE = Nothing
End Function