I ended up using RegExp and string concat.