Is this for interactive use? I suppose so. As the doc string for replace-regexp says:
This function is for interactive use only; in Lisp code
use `re-search-forward' and `replace-match' instead.
Are you really asking about replace-regexp, and not query-replace-regexp?
Because if you use the latter then the answer is included in Isearch by default: ...