Applescript 有没有办法从返回的文本中删除某些单词?

Applescript 有没有办法从返回的文本中删除某些单词?,applescript,Applescript,这里是noob编码器 我试图创建一个程序,从用户返回的句子中删除某些单词 到目前为止,我得到的是: set returnedSentence to display dialog "Welcome to SimpleScript Early Release (Beta)! To continue please enter your desired code/text." default answer "" buttons {"Go!", "Cancel"} default button 1

这里是noob编码器

我试图创建一个程序,从用户返回的句子中删除某些单词

到目前为止,我得到的是:

    set returnedSentence to display dialog "Welcome to SimpleScript Early Release (Beta)! To continue please enter your desired code/text." default answer "" buttons {"Go!", "Cancel"} default button 1

display dialog returnedSentance - "if" - "and" - "then" - "a" buttons {"ok", "Cancel"} default button 2

例如:如果用户输入以下句子:如果我饿了,那么我会去餐馆

然后代码应该返回我饿了,我会去餐馆


提前感谢。

使用您语言的正则表达式库提取不包含反禁用词的部分

Plain AppleScript没有正则表达式,但您可以使用
文本项分隔符
将所需的文本项替换为无/空白。例如:

set returnedSentence to text returned of (display dialog "Welcome to SimpleScript Early Release (Beta)! To continue please enter your desired code/text." default answer "" buttons {"Go!", "Cancel"} default button 1)

set trimList to {"if ", "and ", "then ", "a "} -- the text items to replace (note the trailing space to denote words)
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, trimList} -- stash original delimiters (normally blank) and set new ones
set trimmedItems to text items of returnedSentence -- break the string apart
set AppleScript's text item delimiters to tempTID -- restore delimiters (normally blank)
set trimmedSentence to trimmedItems as text -- put the string back together

display dialog trimmedSentence buttons {"ok", "Cancel"} default button 2

你的具体问题是什么?你试图用什么方法来解决这个问题?