When using the DataTable. Select method escape methods for special characters are Shared

  • 2020-07-21 07:22:37
  • OfStack


public static string Replace(string oldStr)
        {
            if (string.IsNullOrEmpty(oldStr))
            {
                return "";
            }
            string str2 = Regex.Replace(oldStr, @"[\[\+\\\|\(\)\^\*\""\]'%~#-&]", delegate(Match match)
            {
                if (match.Value == "'")
                {
                    return "''";
                }
                else
                {
                    return "[" + match.Value + "]";
                }
            });
            return str2;
        }

Related articles: