Genius is nothing more than inflamed enthusiasm.
Here we go!
AppleScript (1)
久しぶりのプログラミングで更新がごぶさたになりました。すこしづつ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
今回は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
コメント ( 0 ) | Trackback ( 0 )
« やるな!Apple... | KDX ピストン... » |
コメント |
コメントはありません。 |
コメントを投稿する |