分隔符 - 如何删除最后3文本项 [英] Delimiters - How to remove last 3 text items
本文介绍了分隔符 - 如何删除最后3文本项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
AppleScript的定界符
如何删除最后3文本项目?
我的名单如下:
{水,管理,中,古,希腊,城市,君,1993年,PDF}
我想删除最后3文本项目(例如:君,1993年和PDF
)。
下面是我的脚本到目前为止:
集的AppleScript的文本项分隔符[美国。]
设置stringToUse为04.Oxford.University。press.USA.Water.Mngt.in.Ancient.Greek.Cities.Jun.1993.pdf作为字符串
设置stringUSA为stringToUse的最后文本项
设置的AppleScript的文本项分隔符[。]
设置路径名文本stringUSA项目
返回路径名
一般情况下,重要的是:
- 的列表中的文本项的数量可以是一个变量
- 要删除的文本项总是最后三个
解决方案
尝试:
设置的AppleScript的文本项分隔符为USA。
设置stringToUse为04.Oxford.University。press.USA.Water.Mngt.in.Ancient.Greek.Cities.Jun.1993.pdf作为字符串
设置stringUSA为stringToUse的最后文本项
设置的AppleScript的文本项分隔符。
设置路径名的文本项目1直通stringUSA -4
设置的AppleScript的文本项分隔符{}
返回路径名
AppleScript delimiters
How do I remove the last 3 text items?
My list is as follows:
{"Water", "Management", "in", "Ancient", "Greek", "Cities", "Jun", "1993", "pdf"}
I would like to remove the last 3 text item (e.g.: "Jun, "1993", and "pdf"
).
Here is my script so far:
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
As a general rule it's important that:
- The number of text items in the list can be a variable
- The text items to be deleted are always the last three
解决方案
Try:
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 items 1 thru -4 of stringUSA
set AppleScript's text item delimiters to {""}
return pathNames
这篇关于分隔符 - 如何删除最后3文本项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文