ag:搜索除文件夹名称/子文件夹之外的所有文件夹(Perl Regex) [英] ag: Search all folders except for folderName/subFolder (Perl Regex)

查看:89
本文介绍了ag:搜索除文件夹名称/子文件夹之外的所有文件夹(Perl Regex)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这些文件夹,其中包含子文件夹...

I have these folders that have subfolders in them...

locales/US/en
locales/US/fr
locales/FR/en
locales/FR/fr
locales/DE/en
locales/DE/fr
public
test
[...]

我希望 Silver Searcher 忽略 locales/* 除了 locales/US/en/*(基本上我只关心 US/en> 语言环境文件)

I want Silver Searcher to ignore locales/* EXCEPT for locales/US/en/* (essentially I only care about US/en locale files)

这有效,除了它不显示根目录中的其他文件夹(公共和测试):
ag -l -G '(locales)/(US)'

This works, EXCEPT that it doesn't show the other folders in root (public and test):
ag -l -G '(locales)/(US)'

我相信 AG 使用 Perl 正则表达式.有什么想法吗?

I believe AG uses Perl Regexes. Any thoughts?

推荐答案

如果是 perl 正则表达式,这应该给你预期的结果:

If it is perl regular expressions this should give you the expected result:

^(?:locales/US/en|(?!locales))

说明:

^   = anchor regular expression to start of string.
(?: = group which is not captured
|   = Alternation for alternative capture
(?! = negative look ahead assertion - ensures that the string isnt starting with locales, unless it is starting with locales/US/en

这篇关于ag:搜索除文件夹名称/子文件夹之外的所有文件夹(Perl Regex)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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