How can I insert the character before and after in a character but ignore whitespace between two character or more.
I try this regex but it's return incorrectly
$str = " echo '<pre>';";
$replaces = preg_replace('/(\S{3,})/', '[:$1:]',$str);
var_dump($replaces);
But it's return this following
[:echo:] [:'<pre>';:]
What I want is this
[:echo '<pre>';:]
Thanks in advance