ag: Search all folders except for folderName/subFo

2019-03-06 11:15发布

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
[...]

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

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

I believe AG uses Perl Regexes. Any thoughts?

标签: regex perl ag
1条回答
可以哭但决不认输i
2楼-- · 2019-03-06 11:59

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

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

Explanation:

^   = 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
查看更多
登录 后发表回答