Question
How do I escape a regex (PCRE) to use in bash (with ag)?
Attempts
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
Edit: I was incorrect - the third one above finds nothing (but it does seem to be thinking hard)
I'm using osx
$ bash -version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.