shell - 在 Applescript 中删除部分字符串
问题描述
所以我有一个字符串,但我只想要它在某个部分之后。我知道您最好在 shell 中执行此操作,所以我尝试了,但我有限的 shell 知识并没有让我走得更远。这篇文章试图做类似的事情,但不完全是我需要的。
set theString to "hello/world"
do shell script "echo " & theString & "???"
return theString --the output should be hello
解决方案
不需要 shell 脚本。获取斜杠在字符串中的位置,返回子串从头到尾的位置 - 1
set theString to "hello/world"
set slashIndex to offset of "/" in theString
return text 1 thru (slashIndex - 1) of theString
推荐阅读
- javascript - 让谷歌表格在多列中自动更新时间有点麻烦
- sql - 我可以使用文件 .asp 执行此操作吗?
- reactjs - 使用 -p 标志时出现 webpack 错误
- sql - 如何在Oracle中多次更新与另一个表连接的表?
- python - 如何找到正值最接近零的熊猫记录?
- xaml - 资源字典:System.InvalidCastException
- c# - 我想将一个特定列从我的 DataGrid 导出到 Excel
- mysql - MySQL NOT IN 查询给出错误结果
- reactjs - Material Icons 只是渲染文本,React Materialize
- python - Python3 - 如何按元素的频率对列表进行排序?