获得等同于GNU grep的最简单方法是支持负向倒序? [英] What's the easiest way to get an equivalent to GNU grep that supports negative lookbehinds?

查看:127
本文介绍了获得等同于GNU grep的最简单方法是支持负向倒序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过嵌套子目录中的一堆文件来寻找正则表达式匹配;我的正则表达式需要消极的lookbehind。

I'm trying to grep through a bunch of files in nested subdirectories to look for regular expression matches; my regex requires negative lookbehind.

Perl有负面的后视,但据我可以告诉 GNU grep不支持负向反向

Perl has negative lookbehind, but as far as I can tell GNU grep doesn't support negative lookbehinds.

什么是最简单的方法来获得相当于GNU grep,支持负向lookbehinds?

What's the easiest way to get an equivalent to GNU grep that supports negative lookbehinds?

(我想我可以在Perl中编写我自己的迷你grep,但那不是' t似乎应该是必要的,我的Perl Cookbook的副本包含了tcgrep的源代码;我应该使用什么?如果是这样,最新版本在哪里?不要告诉我必须输入整个程序!)

(I guess I could write my own mini-grep in Perl, but that doesn't seem like it should be necessary. My copy of the Perl Cookbook includes source for tcgrep; is that what I should use? If so, where's the latest version? Don't tell me I have to type this entire program!)

推荐答案

使用 ack ! Ack是用Perl编写的,因此它使用Perl的正则表达式引擎(默认情况下)。

Use ack! Ack is written in Perl so it uses Perl's regex engine (by default).

负面后视是 ack(?< ;!坏)男孩(每willert的评论)

The negative look-behind is ack "(?<!bad)boy" (per willert's comment)

这篇关于获得等同于GNU grep的最简单方法是支持负向倒序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆