使用AppleScript从剪贴板中删除文本 /字符

发布于 2025-02-13 04:15:19 字数 247 浏览 0 评论 0原文

我的剪贴板上有一些文字,这些文本总是具有以下结构

文本?文本

例如:

sampletextsampletext?acb = 1& acb

我想创建一个抓取剪贴板的applescript(Mac快捷方式工作流的一部分),找到?并删除这两个?以及之后的所有文本。之后,将其返回剪贴板。

谢谢你!

I have some text in my clipboard that always has the following structure

text?text

For example:

sampletextsampletext?acb=1&acb

I would like to create an Applescript (part of a Mac Shortcuts workflow) that grabs the clipboard, finds the ? and removes both the ? and all of the text after it. After, return it to the clipboard.

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水中月 2025-02-20 04:15:19
  1. 阅读剪贴板。

  2. 找到的偏移。

  3. 修剪文本(将字符1保持到Offset-1)并将其写回。

     设置thetext以获取剪贴板
    将Questionmarkoffset设置为“?”在TheText
    将剪贴板设置为TheText的文本1(Questionmarkoffset -1)
     
  1. Read the clipboard.

  2. Find the offset of ?.

  3. Trim the text (keep characters 1 to offset-1) and write it back.

    set theText to get the clipboard
    set questionMarkOffset to offset of "?" in theText
    set the clipboard to text 1 thru (questionMarkOffset - 1) of theText
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文