Wouldn’t “x”.join(…) be enough?
Possibly not:
"x".join({'aa'+'bxb'}) == "x".join({'aaxb','b'})
Only if you can guarantee it that possible for someone to sneak in an input that already contains those "x" characters.
Possibly not:
The separator should not be able to show up in the inputs.