using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Text.RegularExpressions;

namespace RemoveNonprintable
{
    public static class StringExtensions
    {
        // Remove characters that are not between ~ and space.
        public static string TrimNonAscii(this string value)
        {
            string pattern = "[^ -~]+";
            return Regex.Replace(value, pattern, "");
        }
    }
}
