似乎无法使用 regxp 进行解析并且无法弄清楚为什么
在尝试从字符串中解析一些数据时,我决定使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
附加组件是否正常工作。您是否尝试过像“.*”这样简单的东西
下面的代码在Applescript中工作:
您可以轻松地将上面的代码包装到一个函数中。
Does the add-on work correctly. Have you tried something simple like ".*"
The following code works in Applescript :
You can easily wrap the above into a function.