Preserve regexp flags. Escape more characters when dumping strings.