Hello, I am quite new in php and I have just started using regular expressions. Could anyone help me with this expression? I don’t know why it is not working.
$string = My name is [[Tom]] and I live in [[Germany|Czech republic]];
$pattern = /[[(.*)[^(]])]|/U
$string = preg_replace("$pattern", “”, $string);
$string = preg_replace("/]/", “”, $string);
echo $string;
I would expect the result to be:
“My name is Tom and I live in Czech republic”
but what I get is “My name is Czech republic”.
The whole part between the first [[ and the sign | is replaced…
I have been fighting with this for hours and didn’t find a solution
Thanks for any help