AppleScript的和&QUOT与......开始;操作者 [英] Applescript and "starts with" operator
本文介绍了AppleScript的和&QUOT与......开始;操作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法来检查(在AppleScript的)如果一个清单(或HTML文本块)以
任意数量的值。
示例(检查单个值)
如果{foobar的开头; P>&LT}然后
- 做一些事情在这里真棒
万一
但我想传递多个值检查< P>
或< H1>
或< EM方式>
先谢谢了。
解决方案
上startswith(TXT,L)
在L V重复
如果TXT用v开头,则返回true
重复结束
假
结束startswithstartswith(ABC,{A,D,E}) - 真
Is there a way to check (in applescript) if a list (or block of html text) starts with
any number of values.
Example (checking for a single value)
if {foobar starts with "<p>"} then
-- do something awesome here
end if
except i would like to pass multiple values to check <p>
or <h1>
or <em>
.
Thanks in advance.
解决方案
on startswith(txt, l)
repeat with v in l
if txt starts with v then return true
end repeat
false
end startswith
startswith("abc", {"a", "d", "e"}) -- true
这篇关于AppleScript的和&QUOT与......开始;操作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文