Search / Replace During Build

Hi, I’m running two different middleman installs and I’m combining them into one site when it gets deployed.
I also have some localization going on, so that one site is build it a locale subfolder.

All in all, this creates some issues with relative / absolute urls as the localhost site generated by Middleman is not eaqual to the build version in terms of root level.

** I would like to know if I can replace specific strings during build.**
Or maybe there is another way of avoiding this “problem”

That would enable me to change the URLs and maintain perfect link structure in both localhost and in build version.