我正在寻找一种快速方法来查找包含 2 个或更多模式的文件夹中的所有文件
grep -l -e foo -e bar ./*
或者
rg -l -e foo -e bar
显示同一行中包含“foo”和“bar”或不同行中包含“foo”或“bar”的所有文件,但我只想要在不同行中至少有一个“foo”匹配和一个“bar”匹配的文件。仅包含“foo”匹配或仅包含“bar”匹配的文件将被过滤掉。
我知道我可以链接 grep 调用,但这太慢了。
我没有得到vim使用python支持.我使用以下配置编译vim 7.4.972:
./configure --enable-shared --with-features=huge --enable-multibyte --enable-cscope
--enable-rubyinterp=yes --enable-pythoninterp=yes --enable-python3interp=yes
--enable-perlinterp=yes --enable-luainterp=yes --enable-gui=auto
--enable-gtk2-check --enable-gnome-check --prefix=/home/me/tools/
--with-global-runtime=/home/me/tools/share/vim/vim74 --with-lua-prefix=/home/me/tools
--with-luajit --enable-fail-if-missing -with-x | tee vim_conf.log
Run Code Online (Sandbox Code Playgroud)
关于python的输出是:
checking --enable-pythoninterp argument... yes
checking for python2... /sw/python/anaconda/bin/python2
checking Python version... 2.7
checking Python is 2.3 or better... yep
checking Python's install prefix... /sw/python/anaconda
checking Python's execution prefix... /sw/python/anaconda
checking Python's configuration directory... /sw/python/anaconda /lib/python2.7/config
checking if -pthread should be used... yes
checking if compile and link flags for Python are sane... yes
checking --enable-python3interp …Run Code Online (Sandbox Code Playgroud) 我想知道如果使用perl正则表达式,这个子字符串的出现次数可以是0或更多次,是否可以从字符串中剪切子字符串?
例如:
"foo bar //baz"并且如果它存在的话,它们都"foo bar"应该导致"foo bar"削减双斜线后面的所有东西.
我知道这可以通过其他方法轻松实现,但我很感兴趣,如果正则表达式oneliner是可能的.
我试过($new_string) = ($string =~ /(.*?)(\/\/)*.*/)
但是那不起作用.