I have an expression [text][id] which should be replaced with a link <a href='id'>text</a>
The solution is (id is integer)
$s = preg_replace("/\[([^\]]+)(\]*)\]\[([0-9]+)\]/","<a href='$3'>$1$2</a>",$string);
However, in some cases (not always!) the expression may be as the following
[text][id][type]
which should in this case be replaced with <a href='id' class='type'>text</a>
Ideas?
\[([0-9]+)\]doing? oridis an integer?textandtype? I think you are going to need 2 regex for this because the replacement is going to need haveclass="$3"everytime, or I guess you could strip it in another step, if empty.