复制代码 代码如下:
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;
}
时间: 2024-10-01 17:46:42