List AppleScript-比较包含其他列表任何部分的作品列表

List AppleScript-比较包含其他列表任何部分的作品列表,list,applescript,compare,List,Applescript,Compare,输入: 输出: set firstList to {'red ball','blue','yellow'} set secondList to {'grasshopper','yellowjacket','blueberry','redball'} 完成这样的事情最好的方法是什么?基本上,我在寻找每个列表中项目之间的相似性。试试: {'yellowjacket','blueberry','redball'} 编辑 编辑2 set matchList to {} set firstLi

输入:

输出:

set firstList to {'red ball','blue','yellow'}
set secondList to {'grasshopper','yellowjacket','blueberry','redball'}
完成这样的事情最好的方法是什么?基本上,我在寻找每个列表中项目之间的相似性。

试试:

{'yellowjacket','blueberry','redball'}
编辑

编辑2

    set matchList to {}
set firstList to {"jamesdoe","jackknow","henryrod"}
set secondList to {"James Doe", "Jack Know", "John Matthews"}

set {TID, text item delimiters} to {text item delimiters, {""}}
repeat with aItem in firstList
    set AppleScript's text item delimiters to {""}
    set myTerm to text items of aItem
    set AppleScript's text item delimiters to {" ?"}
    set myTerm to myTerm as text
    repeat with bItem in secondList
        try
            set end of matchList to (do shell script "echo " & quoted form of bItem & " | grep -Ei " & quoted form of myTerm)
        end try
    end repeat
end repeat

set text item delimiters to TID
return matchList
尝试:

编辑

编辑2

    set matchList to {}
set firstList to {"jamesdoe","jackknow","henryrod"}
set secondList to {"James Doe", "Jack Know", "John Matthews"}

set {TID, text item delimiters} to {text item delimiters, {""}}
repeat with aItem in firstList
    set AppleScript's text item delimiters to {""}
    set myTerm to text items of aItem
    set AppleScript's text item delimiters to {" ?"}
    set myTerm to myTerm as text
    repeat with bItem in secondList
        try
            set end of matchList to (do shell script "echo " & quoted form of bItem & " | grep -Ei " & quoted form of myTerm)
        end try
    end repeat
end repeat

set text item delimiters to TID
return matchList

哇!我真的应该试着去理解更多。。。这正是我要找的!不过有点问题。。我正试图与……结合
将列表1设置为{“詹姆斯多”、“杰克知道”、“亨利罗德”}
将列表2设置为{“詹姆斯多”、“杰克知道”、“约翰·马修斯”
,这将返回
{“詹姆斯多”、“杰克知道”}
。您能详细说明一下吗?对不起,点击
输入
太快了。
将列表1设置为{“詹姆斯多”、“杰克知道”、“亨利罗德”}
将列表2设置为{“James Doe”、“Jack Know”、“John Matthews”
将返回
{“James Doe”、“jackknow”}
抱歉,如果我将上述评论的措辞错误,我不知道如何获得
{“James Doe”、“jackknow”}
而不是
{“James Doe”、“jackknow”}
Wow!我真的应该试着去理解
sed
更多…这正是我想要的!不过有一点问题..我正在尝试合并…
将列表1设置为{“jamesdoe”、“jackknow”、“henryrod”}
将列表2设置为{“jamesdoe”、“Jack Know”、“John Matthews”
,这将返回
{“jamesdoe”jackknow“}
。你能详细说明一下吗?对不起,点击
输入
太快了。
将列表1设置为{“jamesdoe”、“jackknow”、“henryrod”}
将列表2设置为{“jamesdoe”、“jackknow”、“John Matthews”
,返回
{“jamesdoe”、“jackknow”}
很抱歉,如果我把上面的评论说错了,我想不出如何获得
{“jamesdoe”,“jackknow”}
而不是
{“jamesdoe”,“jackknow”}
set matchList to {}
set firstList to {"jamesdoe", "jackknow", "henryrod"}
set secondList to {"James Doe", "Jack Know", "John Matthews"}

set {TID, text item delimiters} to {text item delimiters, {""}}
repeat with aItem in firstList
    set AppleScript's text item delimiters to {""}
    set myTerm to text items of aItem
    set AppleScript's text item delimiters to {" ?"}
    set myTerm to myTerm as text
    repeat with bItem in secondList
        try
            do shell script "echo " & quoted form of bItem & " | grep -Ei " & quoted form of myTerm
            set end of matchList to (aItem's contents)
            exit repeat
        end try
    end repeat
end repeat

set text item delimiters to TID
return matchList