您的位置: bluesailor散记——
« asp.net中login控件,RememberMe可能是个bug在detaiilview的编辑模式,自定义dropdownlist »

在asp.net中统计字符串A在字符串B中出现的次数

分类: .net学习调试笔记 发布: admin 浏览: 日期: 2008年10月19日

思路有多种。

  1. 正则验证匹配
  2. split分割
  3. replace替换算长度

下面以第三种方法举例

            string strReplace = "http";
            int CountHttp = ((strContent.Length - (strContent.Replace(strReplace, string.Empty)).Length)) / strReplace.Length;
 

实现的思路,想算A字符串在B字符串出现的次数.

可以用 (B字符串的长度, 去除含有的A字符串后的B字符串的长度) 除以A字符串的长度。

 

 

 

相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-Blog 1.8 Spirit Build 80722

Copyright Lunji.com Some Rights Reserved.