ag:搜索除folderName / subFolder(Perl Regex)之外的所有文件夹

时间:2016-03-02 07:15:26

标签: regex perl ag

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

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语言环境文件)

这是有效的,除了它不显示root(public和test)中的其他文件夹:
ag -l -G '(locales)/(US)'

我相信AG使用Perl Regexes。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

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

^(?: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