似乎无法使用 regxp 进行解析并且无法弄清楚为什么

发布于 2024-12-15 20:21:40 字数 680 浏览 0 评论 0原文

在尝试从字符串中解析一些数据时,我决定使用 Satimage 的 regxp 添加。但是,我遇到了一些我无法弄清楚的问题。根据文档,默认的正则表达式引擎是 Ruby,这很棒,因为它支持lookbehind 和lookahead,我可以使用它们。我在 Ruby 中测试了我的正则表达式:

ruby-1.9.2-p290 :056 >   ref = "ABCD_oxox\"><title>Reset"
=> "ABCD_oxox\"><title>Reset" 
ruby-1.9.2-p290 :057 > xx = /.*(?=\">)/.match(ref).to_s
=> "ABCD_oxox" 
ruby-1.9.2-p290 :058 > 

所以我知道它有效。但是,在 AppleScript 中,我似乎无法让它工作:

-- AS Begin

set RefID2 to "ABCD_oxox\"><title>Reset"
set xx to find text ".*?(?=\\\">)" in RefID2 with regxp and string result

-- AS end

错误“此表达式的某些部分没有返回结果。”编号-2763

我很困惑...有人知道这个吗?

In trying to parse some data from a string, I decided to use Satimage's regxp addition. However, I'm having some issues with it that I can't quite figure out. According to the documentation, the default regex engine is Ruby, which is great because it supports the lookbehind and lookahead and I can use those. I tested my regular expression in Ruby:

ruby-1.9.2-p290 :056 >   ref = "ABCD_oxox\"><title>Reset"
=> "ABCD_oxox\"><title>Reset" 
ruby-1.9.2-p290 :057 > xx = /.*(?=\">)/.match(ref).to_s
=> "ABCD_oxox" 
ruby-1.9.2-p290 :058 > 

So I know it works. However, in AppleScript, I can't seem to get it to work:

-- AS Begin

set RefID2 to "ABCD_oxox\"><title>Reset"
set xx to find text ".*?(?=\\\">)" in RefID2 with regxp and string result

-- AS end

error "No result was returned from some part of this expression." number -2763

I'm stumped... anybody got a clue on this one?

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

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

发布评论

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

评论(1

烟凡古楼 2024-12-22 20:21:40

附加组件是否正常工作。您是否尝试过像“.*”这样简单的东西

下面的代码在Applescript中工作:

set aa to "ABCD_oxox\"><title>Reset"
set aa to "puts /.*(?=\">)/.match(" & quoted form of aa & ").to_s"
do shell script "ruby -e " & quoted form of aa

您可以轻松地将上面的代码包装到一个函数中。

Does the add-on work correctly. Have you tried something simple like ".*"

The following code works in Applescript :

set aa to "ABCD_oxox\"><title>Reset"
set aa to "puts /.*(?=\">)/.match(" & quoted form of aa & ").to_s"
do shell script "ruby -e " & quoted form of aa

You can easily wrap the above into a function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文