goo blog サービス終了のお知らせ 

Here we go!

Genius is nothing more than inflamed enthusiasm.

AppleScript (1)

2004-12-17 | Computer
久しぶりのプログラミングで更新がごぶさたになりました。すこしづつAppleScriptライブラリも増えてきましたので、メモ代わりにかきとめます。

今回はTextを扱う自作ライブラリをひとつ(使用は自由ですが、自己責任でどうぞ)。
・delimiteredWith … 文字列を分割
・replaceString … 文字列を置換
・removeString … 文字列から任意の文字を削除
・includeString … 文字列が含まれているか否か

Here we go!

--------------------------------
-- <delimiteredWith >
--------------------------------
on delimiteredWith(aString, aDelimiter)
set AppleScript's text item delimiters to aDelimiter
return (text items of aString)
end delimiteredWith

--------------------------------
-- <replace string >
--------------------------------
on replaceString(aSource, aOldString, aNewString)
set aString to aSource as string
set AppleScript's text item delimiters to (aOldString as string)
set aString to (text items of aString)
set AppleScript's text item delimiters to (aNewString as string)
return aString as string
end replaceString

--------------------------------
-- <remove string >
--------------------------------
on removeString(aSource, aRemoval)
return my replaceString(aSource, aRemoval, "")
end removeString

--------------------------------
-- <include string >
--------------------------------
on includeString(aSource, aSearch)
return not (my removeString(aSource, aSearch as string) = aSource as string)
end includeString

最新の画像もっと見る

コメントを投稿

サービス終了に伴い、10月1日にコメント投稿機能を終了させていただく予定です。