AppleScript:字符串中子字符串的索引
我想创建一个函数,返回特定字符串的子字符串,从该字符串的开头一直到但不包括另一个特定字符串的开头。有想法吗?
因此,
substrUpTo(theStr, subStr)
如果我输入 substrUpTo("Today is mybirth", "my")
,它将返回第一个参数的子字符串,直到但不包括第二个参数开始的位置。 (即它会返回“今天是”
)
I want to create a function that returns a substring of a specific string from the beginning of said string up to but not including the start of another specific string. Ideas?
So something like:
substrUpTo(theStr, subStr)
so if I inputted substrUpTo("Today is my birthday", "my")
, it would return a substring of the first argument up to but not including where the second argument begins. (i.e. it would return "Today is "
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
内置
offset
命令应该执行此操作:The built-in
offset
command should do it:可能有点笨拙,但它完成了工作......
Probably a bit kludgey, but it gets the job done...