コード例 #1
0
        /// <summary>
        /// Sanitizes the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="sanitationMode">The sanitation mode.</param>
        /// <returns></returns>
        public static string Sanitize(string text, TextSanitationMode sanitationMode)
        {
            switch (sanitationMode)
            {
            case TextSanitationMode.Alphanumeric:
                return(Regex.Replace(text, "[^a-z0-9]+", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Multiline));

            default:
                throw new NotImplementedException("The requested sanitation mode has not been implemented.");
            }
        }
コード例 #2
0
 /// <summary>
 /// Sanitizes the specified text.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="sanitationMode">The sanitation mode.</param>
 /// <returns></returns>
 public static string Sanitize(string text, TextSanitationMode sanitationMode)
 {
     switch (sanitationMode)
     {
         case TextSanitationMode.Alphanumeric:
             return Regex.Replace(text, "[^a-z0-9]+", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Multiline);
         default:
             throw new NotImplementedException("The requested sanitation mode has not been implemented.");
     }
 }