private static string ReplaceEx(string original,
string pattern, string replacement)
{
int count, position0, position1;
count = position0 = position1 = 0;
string upperString = original.ToUpper();
string upperPattern = pattern.ToUpper();
int inc = (original.Length/pattern.Length) *
(replacement.Length-pattern.Length);
char [] chars = new char[original.Length + Math.Max(0, inc)];
while( (position1 = upperString.IndexOf(upperPattern,
position0)) != -1 )
{
for ( int i=position0 ; i < position1 ; ++i )
chars[count++] = original[i];
for ( int i=0 ; i < replacement.Length ; ++i )
chars[count++] = replacement[i];
position0 = position1+pattern.Length;
}
if ( position0 == 0 ) return original;
for ( int i=position0 ; i < original.Length ; ++i )
chars[count++] = original[i];
return new string(chars, 0, count);
}
http://www.codeproject.com/KB/string/fastestcscaseinsstringrep.aspx
分享到:
相关推荐
C# 2010 offers powerful new features, and this book is the fastest path to mastering them—and the rest of C#—for both experienced C# programmers moving to C# 2010 and programmers moving to C# from ...
C# 2010 offers powerful new features, and this book is the fastest path to mastering them—and the rest of C#—for both experienced C# programmers moving to C# 2010 and programmers moving to C# from ...
C# 2010 offers powerful new features, and this book is the fastest path to mastering them—and the rest of C#—for both experienced C# programmers moving to C# 2010 and programmers moving to C# from ...
C# 2008 offers powerful new features, and Accelerated C# 2008 is the fastest path to mastery, for both experienced C# programmers moving to C# 2008 and programmers moving to C# from another object-...
Youll also learn best practices that ensure your code will be efficient, reusable, and robust. <br>This book is the fastest path to C# mastery for anyone familiar with object-oriented programming....
Fastest way to build an HTML stringPosted in ‘Code Snippets, JavaScript’ by James on May 29th, 2009 原文:http://james.padolsey.com/javascript/fastest-way-to-build-an-html-string/ 代码如下: var arr...
wp-fastest-cache-premium-1.5.8
WP Fastest Cache Premium-WordPress静态缓存插件,官方原版无修改,须配合免费版使用(同时启用免费版及本专业版),免费版自行在wordpress-plugins搜索按照即可。 功能: 发布新文章会更新插件缓存文件 缓存文件...
wordpress最好用的网页缓存插件,除图片压缩功能外,一切正常,可在后台直接更新最新版,先安装wp fastest cache,再安装wp fastest cache Premium,有汉化语言包
用opencv的dnn模块实现Yolo-Fastest的目标检测.zip用opencv的dnn模块实现Yolo-Fastest的目标检测.zip用opencv的dnn模块实现Yolo-Fastest的目标检测.zip用opencv的dnn模块实现Yolo-Fastest的目标检测.zip用opencv的...
wp-fastest-cache-premium-v1.5.7
最快的字符串实用程序是用于字符串操作的Java库(JAR)。 该库在字符串操作(例如split,toUpperCase,toLowerCase,替换,删除,正则表达式等)中非常易于使用,非常快速且非常有效。
The professional programmer’s Deitel guide to Pythonwith introductory artificial intelligence case studies Written for programmers with a background in another high-level language, this book uses ...
用opencv的dnn模块实现Yolo-Fastest的目标检测python源码+模型+说明.zip用opencv的dnn模块实现Yolo-Fastest的目标检测python源码+模型+说明.zip用opencv的dnn模块实现Yolo-Fastest的目标检测python源码+模型+说明....
fastest algorithm to find EMD.
WAV2LETTER++: THE FASTEST OPEN-SOURCE SPEECH RECOGNITION SYSTEM 论文原文
最快的左乙视黄素 :rocket: 最快JS / TS实现。...// Print string from array with lowest edit-distance to 'fast' console . log ( closest ( 'fast' , [ 'slow' , 'faster' , 'fastest' ] ) ) //=> 'faster
utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromBaidu-1.not_u
[2010] Integrating CMMI and Agile Development - Case Studies and Proven Techniques for Faster Performance Improvement.(Paul E. McMahon).[0321714105].pdf Paperback: 368 pages Publisher: Addison-...