Replace invalid characters with empty strings by using Regular expression
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.IO;
namespace Billing
{
public class StringUtils
{
public static String CleanInput(string str)
{
// Replace invalid characters with empty strings.
return Regex.Replace(str, @"[^\w ]", "");
}
}
}
Related examples in the same category