in reply to Problem: how to split long words

So far, I have:

$text = 'ju[color=1]s[/color]t a tes[color=2]t[/color]'; $text =~ s/ ( (?: (?: \[ [^]]* \] )* [^ [] ){3} (?: \[ [^]]* \] )* ) (?=[^ ]) /$1-/gx; print($text, "\n"); # ju[color=1]s[/color]-t a tes[color=2]-t[/co-lor-]

It's not quite there yet, but I have to go.