AppleScript 分隔符
如何删除最后 3 个文本项?
我的清单如下:
{"Water", "Management", "in", "Ancient", "Greek", "Cities", "Jun", "1993", "pdf"}
我想删除最后 3 个文本项(例如:)"Jun, "1993", and "pdf"
。
到目前为止,这是我的脚本:
set AppleScript's text item delimiters to ["USA."]
set stringToUse to "04.Oxford.University.Press.USA.Water.Mngt.in.Ancient.Greek.Cities.Jun.1993.pdf" as string
set stringUSA to last text item of stringToUse
set AppleScript's text item delimiters to ["."]
set pathNames to text item of stringUSA
return pathNames
作为一般规则,重要的是:
- 列表中文本项的数量可以是变量
- 要删除的文本项始终是最后三个