Ubuntu 12.04 で Libreoffice 3.5.7.2 を使用します。
計算セルに次の形式のテキストがあります: (IBM) Ibm Corporation.
基本的なマクロを使用して、正規表現を使用して () の間のテキストを抽出しようとしています。これは私がこれまでに試したことです。
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
myRegex.SearchString 行には、私が試したさまざまなバージョンが含まれています。結果は常に同じです。() の間のテキストだけでなく、セルの内容全体が返されます。() の間のテキストだけを抽出する方法はありますか?
ありがとう、ジム