110,536
社区成员
发帖
与我相关
我的任务
分享
public static bool Find(string str, string target)
{
return Regex.Matches(str, @"\d{2}").Cast<Match>().Select(x => x.Value).Contains(target);
}
string[] ss = { "01", "02", "03", "04", "05" };
string str = "0702110409";
bool r = Regex.Matches(str, @"\d{2}").Cast<Match>().Select(x => x.Value).Any(x => ss.Contains(x));
Response.Write(r);
public bool Find(string str, string target)
{
for (int n = 0; n < str.Length - 1; n += 2)
{
if (str[n] == target[0] && str[n + 1] == target[1])
return true;
}
return false;
}
bool b1=Find("0702110409","10"); //结果是false
bool b2=Find("0702110409","11"); //结果是true