110,539
社区成员
发帖
与我相关
我的任务
分享
string s = @"[www.\cntingshu.com]百家讲坛_";
string pattern = s;
bool result = Regex.IsMatch(s, Regex.Escape(pattern));
Response.Write(result);
//true
public static string StringToPattern(string Str)
{
if(Str=="")
return "";
string[] c={"\\", "^", "$", "{", "[", ".", "(", "*", "+", "?", "!", "#", "|",")"};
for(int i=0;i<c.Length;i++)
{
Str=Str.Replace(c[i],"\\"+c[i]);
}
return Str;
}