次の作業例の AppleScript スニペットがあります。
set str to "This is a string"
set outlist to {}
repeat with wrd in words of str
if wrd contains "is" then set end of outlist to wrd
end repeat
AppleScript の who 句を使用して、このような繰り返しループを置き換えてパフォーマンスを大幅に向上させることができることを私は知っています。ただし、単語、文字、段落などのテキスト要素リストの場合、これを機能させる方法を見つけることができませんでした。
私が試してみました:
set outlist to words of str whose text contains "is"
これは次の場合に失敗します。
error "Can’t get {\"This\", \"is\", \"a\", \"string\"} whose text contains \"is\"." number -1728
、おそらく「テキスト」はテキストクラスのプロパティではないためです。テキスト クラスのAppleScript リファレンスを見ると、「引用されたフォーム」がテキスト クラスのプロパティであることがわかります。
set outlist to words of str whose quoted form contains "is"
しかし、これも失敗し、次のようになります。
error "Can’t get {\"This\", \"is\", \"a\", \"string\"} whose quoted form contains \"is\"." number -1728
このような繰り返しループを AppleScript の who 句に置き換える方法はありますか?