cxi変換文字列のすべての正則特殊文字方法の例
/// <summary>
///
/// </summary>
/// <param name="input"> </param>
/// <returns></returns>
string FilterString(string input)
{
input = input.Replace("\\", "\\\\");// “\”, “\”
Regex r = new Regex("[\\*\\.\\?\\+\\$\\^\\[\\]\\(\\)\\{\\}\\|\\/]");
MatchCollection ms = r.Matches(input);
List<string> list = new List<string>();
foreach (Match item in ms)
{
if (list.Contains(item.Value))
continue;
input = input.Replace(item.Value, "\\" + item.Value);
list.Add(item.Value);
}
return input;
}