Using Libreoffice 3.5.7.2 on Ubuntu 12.04.
I have text in calc cells in the form of: (IBM) Ibm Corporation.
I am trying to use regex to extract the text between the ()'s using a basic macro. This is what I have tried so far.
Sub getMktValue()
Dim oDoc as Object
Dim oSheet as Object
Dim oCell as Object
oDoc = ThisComponent
oSheet = oDoc.Sheets.getByName("Income")
'regex test code'
oCell = oSheet.getCellByPosition(0, 1)
stk = oCell.String()
myRegex = oCell.createSearchDescriptor
myRegex.SearchRegularExpression = True
myRegex.SearchString = "\((.*)\)" '"[\([A-Z]\)]" "\(([^)]*)\)" "\(([^)]+)\)"'
found = oCell.FindFirst(myRegex)
MsgBox found.String
End Sub
The myRegex.SearchString line contains the various versions I have tried. The result is always the same. The entire contents of the cell are returned not just the text between the ()'s. Is there a way to extract just the text between the ()'s?
Thanks, Jim