下面是一个使用正则表达式搜索字符串的一段代码:
string[] zhous=
{
"C# wo de zui ai",
"C# si very good",
"Beijing huan ying ni",
"Zhong Guo 2009",
};
string zhous="^C
foreach(string s in zhous)
{
Console.Write("{0,32}",); ————————————→(这个代表什么?)
if(Regex.IsMatch(s,sPatten,RegexOptions.IgnoreCase)) ————————————→(这个代表什么?)
{
Console.WriteLine(" (mach for '{0}' found)",sPatten);
}
else
{
Conlose.WriteLine(" no mach here!");
}
}
Console.ReadLine();
string[] zhous=
{
"C# wo de zui ai",
"C# si very good",
"Beijing huan ying ni",
"Zhong Guo 2009",
};
string zhous="^C
foreach(string s in zhous)
{
Console.Write("{0,32}",); ————————————→(这个代表什么?)
if(Regex.IsMatch(s,sPatten,RegexOptions.IgnoreCase)) ————————————→(这个代表什么?)
{
Console.WriteLine(" (mach for '{0}' found)",sPatten);
}
else
{
Conlose.WriteLine(" no mach here!");
}
}
Console.ReadLine();
{
string[] zhous =
{
"C# wo de zui ai",
"C# si very good",
"Beijing huan ying ni",
"Zhong Guo 2009",
};
string sPatten = "^C";
foreach (string s in zhous)
{
Console.Write("{0,32}", s); //————————————→(这个代表什么?) if (Regex.IsMatch(s, sPatten, RegexOptions.IgnoreCase)) // ————————————→(这个代表什么?)
{
Console.WriteLine(" (mach for '{0}' found)", sPatten);
}
else
{
Console.WriteLine(" no mach here!");
}
}
Console.ReadLine(); }
刚开始学,失误了自己都不知道。。呵呵
顺便问句LZ 是什么意思?