I need to perform regex query replace, such that
foo in foo bar is matched, but foo in foo baz is not. Normally I would use regex look ahead, e.g. foo(?=bar).
However, it seems like Emacs cannot do this? Vim seems capable, but evil mode in spacemacs cannot.

perlcan work in some use cases. – HappyFace Sep 19 '21 at 07:25