I'm seeing this answer relatively high on Google, while the other answers are right in your use case, they do not hold up in other use cases.
Regex does not scale well, just taking the example benchmark by Seblor, but replacing the string "hello world" by the book Othello by William Shakespeare (I'm not linking a code, the string is 5730 lines long, but you are welcome to follow this link that has the full document: https://shakespeare.mit.edu/othello/full.html)
The benchmark results are a 40% reduction in ops:
split & join x 1,486 ops/sec ±0.55% (12 runs sampled)
replace regex x 916 ops/sec ±0.26% (63 runs sampled)
replaceAll x 906 ops/sec ±0.71% (9 runs sampled)
replaceAll with regex x 910 ops/sec ±0.72% (63 runs sampled)
The more nuanced answer is that you need to verify those points:
How long is your string? the longer the string, the less efficient the regex will be. Running a regex on a small string will be faster than split and join, but on a long string, split and join will almost always outperform the regex.
How complex is your regex? Matching simple spaces is fast, but the more complicated it will be, the more expensive the regex will become. This is the basis of ReDOS attacks that slow down your server by sending strings that will hog down a poorly made regex.
And finally, how can you verify this? the tool https://regex101.com/ can help you verify the complexity and speed of a regex, by giving you the number of steps required to match your regex: more steps = slower.
replaceAll
is slower, and with big strings even more slow!