有沒有辦法檢查(在applescript中)是否有任何數量的值的列表(或HTML文本塊)starts with
。Applescript和「開始」運算符
實施例(檢查單個值)
if {foobar starts with "<p>"} then
-- do something awesome here
end if
除我想傳遞多個值,以檢查<p>
<h1>
或或<em>
。
在此先感謝。
有沒有辦法檢查(在applescript中)是否有任何數量的值的列表(或HTML文本塊)starts with
。Applescript和「開始」運算符
實施例(檢查單個值)
if {foobar starts with "<p>"} then
-- do something awesome here
end if
除我想傳遞多個值,以檢查<p>
<h1>
或或<em>
。
在此先感謝。
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的「英語」的風格中,雖然比上面的例子更長的時間,你可以這樣做:
if {foobar starts with "hello" or foobar starts with "goodbye"} then
一個完整的例子是:
set foobar to "hello dude"
if {foobar starts with "hello" or foobar starts with "goodbye"} then
display dialog "found"
end if
這將是真實的,即使你改變:
set foobar to "hello dude"
到:
set foobar to "goodbye dude"
有趣的信息。我在另一個頁面上發佈了與此問題有關的另一個問題。 @Lri非常友好,可以爲這個問題創建一個合適的解決方案[here](http://stackoverflow.com/questions/5932752/applescript-wrap-lines-with-html-tags-and-marsedit-app-script-問題) – VicePrez 2011-05-11 09:27:27
工作在自己的LRI偉大的,但我怎麼能這個腳本中實現它。我一點都不熟練。下面是一個關於pastebin的鏈接http://pastebin.com/mS3wyYQX – VicePrez 2011-05-08 21:39:45
@VicePrez這將需要另一個問題。這裏有一些相似的東西:[wrap_lines_with_tag.applescript](http://cs.helsinki.fi/u/lranta/pastebin/wrap_lines_with_tag.applescript) – user495470 2011-05-08 23:26:26
謝謝里夫,虐待嘗試與你給我的人一起工作,如果它不工作生病發布了另一個與我目前有關的問題。 +1 – VicePrez 2011-05-09 04:36:15