I'm trying to replace the ~
into |
between the [
]
in the folowwing case:
{stackoverflow is a [cool~great~fast] website ~ Find your answers [easily~quickly] on stackoverflow}.
Note: The text between the [
]
can be multiline.
I've tried multiple regexs buth with no luck.
My closest call at the moment is:
$text = preg_replace("/\[(.*?)~(.*?)\]/i", "[$1|$2]", $text);
But that returns
{stackoverflow is a [cool~great|fast] website ~ Find your answers [easily|quickly] on stackoverflow}.