Kev*_*vin 4 applescript if-statement contain
我有一个脚本,用于查找名称并搜索与另一个变量的匹配项。
它工作正常,但是如果变量 1 是“Name Demo”而变量 2 是“Demo Name”,则脚本找不到匹配项。
set nameMatchTXT to ""
if NameOnDevice contains theName then
set nameMatch to theName & " : Name Match"
end if
Run Code Online (Sandbox Code Playgroud)
无论如何改变这个以找到匹配的顺序?PS 脚本正在寻找单词通配符,有时处理双位字符可能会很困难。
您的要求指出:
如果变量 1 是“Name Demo”,变量 2 是“Demo Name”,则脚本找不到匹配项。
这将解决这个问题:
set var1 to "Name Demo"
set var2 to "Demo Name"
if (var2 contains (word 1 of var1)) and (var2 contains (word 2 of var1)) then
-- you have a match
display dialog "var1 and var2 match"
else
display dialog "no match"
end if
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11904 次 |
| 最近记录: |