Rewrite strings based on a set of known prefixes
