maybe try use  $chr(91) = [ and $chr(93) = ], don't know if it help, but you can try use $replace for this..