问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/35740753/ag-search-all-folders-except-for-foldername-subfolder-perl-regex