加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在Geany中,正则表达式搜索中的负面观察是否可行?

发布时间:2020-12-13 22:54:17 所属栏目:百科 来源:网络整理
导读:Geany’s documentation on negative assertions让它看起来像是可能的. 作为参考,这是有效的,并给我结果: pcregrep -r "(?!= )function(" src/main-js/ 但同样的正则表达式,或任何具有负面背后的正则表达式,从Geany启动时都没有给我任何结果(v 1.24.1) 问
Geany’s documentation on negative assertions让它看起来像是可能的.

作为参考,这是有效的,并给我结果:

pcregrep -r "(?<!= )function(" src/main-js/

但同样的正则表达式,或任何具有负面背后的正则表达式,从Geany启动时都没有给我任何结果(v 1.24.1)

问题出在哪儿 ?文档错了吗?

精确度:主题不是关于如何避免背后的负面看法,而是关于如何做任何标准的PCRE负面看.

我得到了freenode上geany开发者的支持.很有帮助.这是他们告诉我的:

The documented RE syntax only applies to the RE engine directly used by
Geany (e.g. in Find),but the Find in Files features calls the grep tool
(as configured in preferences->tools->grep),which has its own syntax.
For GNU grep,you can add “-P” to the “Extra options” field in the
dialog

但是,在您尝试之后,您遇到了以下错误:

/bin/grep: conflicting matchers specified

…我被告知这是一个geany bug. Geany调用grep -E,-P与它不兼容.

您唯一的解决方法是让shell脚本使用-P而不是-E调用grep,并使用此脚本.您应该能够配置grep工具以调用geany首选项.

所述shell脚本的一个例子:

#!/bin/sh

matchopts=$(echo "$1" | tr E P)
shift

exec grep $matchopts "$@"

对于grep,Geany使用either -F or -E(这些是POSIX grep中唯一可用的引擎),因此为什么你不能传递-P.

我已经向geany开发者报告了the bug.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读