Fix and improve rst_char_len

The previously used regex was plainly wrong (see #394). This solution should be more solid.