Why not just use $len()? Here's just a quick example. You could improve on this by combining some things to reduce some calculations, but I wanted it to clearly show what was happening.

Code:
on *:input:#:{
  if $left($1,1) != / {
    var %1 12,11, %2 11,14, %l = $int($calc($len($1-) / 2)), %r = $round($calc($len($1-) / 2),0)
    echo # %1 $+ $left($1-,%l) $+ %2 $+ $right($1-,%r)
    haltdef
  }
}