Regex r = new Regex(childstr);
str = r.Replace(str, "", 1);
已知一个字符串,比如asderwsde,寻找其中的一个子字符串比如sde 的个数,如果没有返回0,有的话返回子字符串的个数
public static int getnum(string str,string childstr){int num = 0;if (str == "" || childstr == ""){return num;}while (str.IndexOf(childstr) > 0){Regex r = new Regex(childstr);str = r.Replace(str, "", 1);num++;}return num;}