如题,实在没有C#的,C的也可以
最好有注释~
最好有注释~
解决方案 »
- List中的元素不能修改?
- 文件名、目录名或卷标语法不正确。
- Linq to sql 查询
- teechart值怎么设置???(C#)
- [求援] 愚翁老大~~請進~~WMI的問題~~~
- 水晶报表--动态数据源--涉及两个表! 第一问题已解决,在CrystalReport中显示两个表,怎样处理呀?
- 关于socket 和多线程的问题
- freetextbox:如何从freetextbox工具栏弹出一个网页。在弹出的网页中操作freetextbox中的一个脚本函数。
- 如何实现DataGrid中打货品代码,后面自动出现货品的名称和规格(WinForm),类似Delphi的计算字段
- XmlWriter如何给某一元素值付十六进制字符串?
- WEB页面中水晶报表的两个问题
- 有没有用C#编写的在线编辑器
string yourStr = ......;//这个页面Ctrl+A,Ctrl+C
Regex regex = new Regex("跪求|维也纳", RegexOptions.IgnoreCase);
MatchCollection mc = regex.Matches(yourStr);
Dictionary<string, int> key = new Dictionary<string, int>;
key.Add("跪求", 0);
key.Add("维也纳", 0);
foreach(Match m in mc)
{
if(m.Value == "跪求")
{
key["跪求"]++;
}
else
{
key["维也纳"]++;
}
}
要求高执行效率,C#可能要用Unsafe代码
C#,VB.NET的都有
http://dotnetjunkies.com/Tutorial/195E323C-78F3-4884-A5AA-3A1081AC3B35.dcik
sm.cs © 2007 by Shuiwatermizu
1. scan the original string from the start.
2. look for all the string in lookfor array.
if found, scan the original string from the position after the found string
if not found, scan the next character of the original string
This method is faster than regex.
*/
using System;
using System.Diagnostics;public class T
{ public static void Main()
{
string original=@"onetwothreefour";
string[] lookfor=new string[]{"two", "four"};
string[] replacewith=new string[]{"twenty", "forty"};
Console.WriteLine("After replace: {0}", ReplaceEx2(original, lookfor, replacewith));
}//end of Main() public static string ReplaceEx2(string original, string[] lookfor, string[] replacewith)
{
int increasedSize=0;
for (int t=0;t<lookfor.Length;t++)
{
increasedSize+=replacewith[t].Length-lookfor[t].Length;
}
int retLen=original.Length+increasedSize;//Adjust this value to accomodate the result string.
char[] ret=new char[retLen];
int i=0; //position of the original string
int j=0; //position of the result.
int m=0;
while (i<original.Length)
{
for (m=0;m<lookfor.Length;m++)//loop through all the search strings
{
int n=0;
while (n<lookfor[m].Length)//loop through a single search string
{
if (i+n<original.Length)
{
if (lookfor[m][n]!=original[i+n])
break;//not found
}
else
break;
n++;
}
if (n==lookfor[m].Length)//found match of lookfor[m]
{
Console.WriteLine("match {0} at position {1}", lookfor[m], i);//DoFoundOperation();
for (int k=0;k<replacewith[m].Length;k++)
ret[j+k]=replacewith[m][k];
j+=replacewith[m].Length;
i+=lookfor[m].Length;
break;
}
}
if (m==lookfor.Length)//not match all the search string
{
ret[j]=original[i];
j++;
i++;
}
}//loop through the total string.
return (new string(ret));
}
}
不行、?
TO:楼主是MM????嗯,是的..
Top
viena(维也纳nn-下潜15米,潜望镜升起) ( ) 信誉:100 Blog 2007-01-16 12:51:10 得分: 0
我不是MM,楼上是我女朋友~
Top
liujia_0421(SnowLover) ( ) 信誉:100 Blog 2007-01-16 12:59:18 得分: 0
^_^
Top
============================
TQ贴~~