 XText
 XText
              XText は、AppleScript のテキストオブジェクトを拡張する、AppleScript ライブラリです。
文字列の置換や分割、空白の除去など、様々なテキスト操作をオブジェクト指向のスタイルで行うことができます。
Using Class Methods
use XText : script "XText"
tell XText
store_delimiters() -- storing AppleScript's text item delimiters
log (replace for "this is a pen" from "pen" by "flower")
-- result : "this is a flower"
set a_list to split("this is a pen", space)
log a_list -- result : {"this", "is", "a", "pen"}
log join_list(a_list, "-") -- result : "this-is-a-pen"
log strip("  this is a pen   ") -- ressult : "this is a pen"
log strip_beginning("   this is a pen   ")
-- result : {"   ", "this is a pen  "}
log strip_endding("  this is a pen   ")
-- result : {"   ","   this is a pen"}
log formatted_text("$1 is $2.", {"XText", "useful"})
-- result : "XText is useful."
restore_delimiters() -- restoring AppleScript's text item delimiters
end tell
Using Instance Methods
use XText : script "XText"
(* Make a XText Instance *)
set x_text to XText's make_with("this is a pen")
set x_text to XText's make_with_list({"this", "is", "a", "pen"}, space)
(*Replacing *)
log x_text's replace("pen", "flower")
-- result : [XText] this is a flower
(* Appending and Prepennding *)
set spaced_text to x_text's prepend(return & tab)
set spaced_text to spaced_text's push(space)
log spaced_text
(*[XText] 
this is a pen *)
(* Stripping *)
log spaced_text's strip() -- result : [XText] this is a pen
set a_result to spaced_text's strip_beginning()
log item 1 of a_result
(*
*)
log item 2 of a_result
-- result : [XText] this is a pen
set a_result to spaced_text's strip_endding()
log item 1 of a_result
(* *)
log item 2 of a_result
(*[XText] 
this is a pen*)
(*Check Contents *)
log x_text's starts_with("this") -- (*true*)
log x_text's ends_with("this") -- (*false*)
log x_text's include("is") -- (*true*)
log x_text's offset_of("is") -- (*3*)
(* Make a list with splitting *)
log x_text's as_list_with(space) -- result : {"this", "is", "a", "pen"}
(* Obtain a part of text *)
log x_text's character_at(1) -- result : [XText] t
log x_text's word_at(1) --  result : [XText] this
log x_text's paragraph_at(1) -- result : [XText] this is a pen
(* Obtain of AppleScript's text properties *)
log character 1 of x_text -- result : "t"
log word 1 of x_text -- result : "this" 
log length of x_text -- result : 13
(* Obtain content as AppleScript's text *)
log x_text's as_text() --(*this is a pen*)
更新履歴
- 1.4 -- 2020-06-17- XList への依存性を削除。
- as_xlist_with を削除
            - XList の make_with_xtext を使ってください。
 
- make_with_list, make_with_xlist, as_list を追加
- as_list_with でデリミタとしてリストを受け取れるようにした。
- replace で置換テキストとしてリストを設定できるようにした。
 
- 1.3.2 -- 2020-01-27
        - HelpBook.osax の代わりに OpenHelpBook.scptd を使うようにした。
- sprintf ハンドラを追加。
- 日本語の ヘルブブックを削除。
 
- 1.3.1 -- 2017-05-08
        - ヘルプブックの不具合を修正
            - XList へのリンクを修正。
- サンプルコードのスクリプトリンクが動作しない不具合を修正。
 
 
- ヘルプブックの不具合を修正
            
- 1.3 -- 2016-10-19
        - OS X 10.9 で登場した AppleScript Libraries で使えるようにした。
- ModuleLoader への依存性をなくした。
- OS X 10.9 以降が必要です。
 
- 1.2.2 -- 2015-09-04
        - character_at は、XText のインスタンスを返すようにした。
 
- 1.2.1 -- 2012-04-22
        - formattd_text の第2引数で、text を渡せるようにした。
- strip, strip_beginning, strip_endding で、BEL (character id 7) も除去するようにした。
- ヘルプをアップデート。
            - Mac OS X 10.6 で、"Edit Script" リンク、ハンドラのコピーリンクが動作しない不具合を修正。
 
 
- 1.2 -- 2010-02-02
        - ModuleLoader 2.1 以降に対応。
- ShowHelpBook への依存性を無くした。
- join を join_list に変更。
 
- 1.1 -- 2008-03-19
        - 日本語マニュアルを追加
- StringEngineへの依存性をなくした。
- テキスト処理の為のクラスメソッドを追加
 
- 1.0 -- 2007-07-10
        - First Release
 
 
     必要なシステム
                  必要なシステム
                 ダウンロード
                ダウンロード 古いバージョン
 古いバージョン 
 
                 
                 依存モジュール
                  依存モジュール
                 Repository
		                Repository