Within an Excel column I have data such as:
"Audi (ADI), Mercedes (modelx) (MEX), Ferrari super fast, high PS (FEH)"
There hundreds of models that are described by a name and an abbreviation of three capitalized letters in brackets.
I need to extract the names only and the abbreviations only to separate cells. I succeeded doing this for the abbreviations by the following module:
Function extrABR(cellRef) As String
Dim RE As Object, MC As Object, M As Object
Dim sTemp As Variant
Const sPat As String = "([A-Z][A-Z][A-Z][A-Z]?)" ' this is my regex to match my string
Set RE = CreateObject("vbscript.regexp")
With RE
.Global = True
.MultiLine = True
.Pattern = sPat
If .Test(cellRef) Then
Set MC = .Execute(cellRef)
For Each M In MC
sTemp = sTemp & ", " & M.SubMatches(0)
Next M
End If
End With
extrABR = Mid(sTemp, 3)
End Function
However, I do not manage to do so for names. I thought of just exchanging the regex by the following regex: (^(.*?)(?= \([A-Z][A-Z][A-Z])|(?<=, )(.*)(?= \([A-Z][A-Z][A-Z])), but VBA does not seem to allow lookbehind.
Any idea?

"\([^)]+\)"... and with second match replace all those with "", you will get a string without abbreviations which you can then split for names.Audi,Mercedes (modelx), andFerrari super fast, high PS?