问题
如何转义正则表达式(PCRE)以在 bash 中使用(使用ag)?
尝试
ag (?!.*rib)(?=.*dist)^(\w+)$ # -bash: !.*wib: event not found
ag "(?!.*rib)(?=.*dist)^(\w+)$" # -bash: !.*wib: event not found
ag '(?!.*rib)(?=.*dist)^(\w+)$' # This does not crash, but finds nothing
ag (\?!.\*rib)(\?=.\*dist)^(\\w+)$ # -bash: !.*wib: event not found
编辑:我错了——上面的第三个什么也没找到(但它似乎在努力思考)
我正在使用 osx
$ bash -version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.