String::RewritePrefix - rewrite strings based on a set of known prefixes.