Skip to main content
deleted 4 characters in body
Source Link
Vadim Ovchinnikov
  • 1.3k
  • 2
  • 12
  • 25

I'd use Regex for this.

public static class StringCleaner
{
    private const Pattern = @"[^a-zA-Z0-9 \#\\\'\(\)\+\,\-\.\/\[\]_`\{\|\}\~\:\?@]";

    public static string Clean(string address, string replacement = "") =>
            Regex.Replace(address, Pattern, replacement);
}

I'd use Regex for this.

public static class StringCleaner
{
    private const Pattern = @"[^a-zA-Z0-9 \#\\\'\(\)\+\,\-\.\/\[\]_`\{\|\}\~\:\?@]";

    public static string Clean(string address, string replacement = "") =>
            Regex.Replace(address, Pattern, replacement);
}

I'd use Regex for this.

public static class StringCleaner
{
    private const Pattern = @"[^a-zA-Z0-9 \#\\\'\(\)\+\,\-\.\/\[\]_`\{\|\}\~\:\?@]";

    public static string Clean(string address, string replacement = "") =>
        Regex.Replace(address, Pattern, replacement);
}
Source Link
Vadim Ovchinnikov
  • 1.3k
  • 2
  • 12
  • 25

I'd use Regex for this.

public static class StringCleaner
{
    private const Pattern = @"[^a-zA-Z0-9 \#\\\'\(\)\+\,\-\.\/\[\]_`\{\|\}\~\:\?@]";

    public static string Clean(string address, string replacement = "") =>
            Regex.Replace(address, Pattern, replacement);
}