/// <summary>
/// 取得指定字符串在源字符串中出现的次数
/// </summary>
/// <param name="str"></param>
/// <param name="sourcestr"></param>
/// <returns></returns>
static int GetStrAppearTimes(string str, string sourcestr)
{
Regex regex = new Regex(str, RegexOptions.IgnoreCase);
var mymatch=regex.Matches(sourcestr);
return mymatch.Count;
}
时间: 2024-09-30 06:55:02