I am not an expert with Regular Expression, so maybe this question has some basic implementation of regex.
First I have retrieve some string from user which has a format like this:
$id =3;
$format = {num}/sometext/sometext;
The question is how to replace {num} with the variable of id, so the result will be :
3/sometext/sometext;
it's kind of like a templating engine.