Replaces text using an asynchronous replacement function.