2012-02-15 55 views
0

我有一個如下所示的文件,它是從我在applescript中編寫的程序輸出的。將OSX上的文本文件格式化爲製表符分隔的文本文件

AXTitle: Blah 
AXSize: Width: 300 
AXSize: Height: 44 
AXPosition: X: 217 
AXPosition: Y: 170 
AXHelp: Blah 
AXValue: Value, On 
AXEnabled: true 
AXFocused: false 
AXRole: AXStaticText 
AXRoleDescription: Blah 
AXTopLevelUIElement: Blah 
AXWindow: Blah 

我需要把一個格式,將與數據庫兼容。所以一個製表符分隔的格式。這是我想在其輸出格式。我不需要上面只是所有的數據我選擇

123 456 0 1 2 3 4 5 text text  
123 456 0 1 2 3 4 5 text text 

我想正則表達式,因爲我需要格式化文本。 我可以在applescript中做這個嗎?如果考慮到我在OSX上開玩笑,不應該考慮什麼程序? sed,gawk,perl,python?我可以在我的applescript程序中插入這些程序,還是需要單獨運行?

回答

1

當你得到你選擇的項目,當您去只需要添加的標籤。您還可以將項目放入列表中,您可以在其中使用文本項目分隔符將項目之間的選項卡轉換爲字符串。

set X to {123, 456, 0, 1, 2, 3, 4, 5, "text", "text"} 
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tab} 
set {X, AppleScript's text item delimiters} to {X as text, tempTID} 

X --> result 
相關問題