Rust regex replace_all slower than PHP regex preg_replace_callback, how to optimize?

Building a regex is an expensive operation that you should do once. You can then use that regex as many times as you need, and it will likely outperform php in replacing all the captures.

So measure the replace_all called many times using the same regex. (On possibly different inputs)

1 Like