Extract repeated regexp to a method
Skip path replacement when it would be a no-op
Ensure cellar path is replace correctly for relocatable bottles
Revert "Disable bottles when HOMEBREW_CELLAR.parent != HOMEBREW_PREFIX"

This reverts commit fdf20dc43971b728520d518f3b6ef0bcb16aeb21.

Closes #24831.
Closes #24780.