`
winyee
  • 浏览: 54047 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Fastest C# Case Insenstive String Replace

    博客分类:
  • Java
阅读更多
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
分享到:
评论

相关推荐

    Accelerated C# 2010 PDF 英文版

    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捷径教程

    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#压缩解压缩支持大文件

    `GZipStream`的构造函数接受一个`CompressionLevel`枚举值,可以选择`Optimal`(最优压缩)、`Fastest`(最快压缩)或`NoCompression`(不压缩)。根据实际需求,平衡压缩速度和文件大小。 2. **内存管理**: ...

    C#实现zip压缩       

    可以使用CompressionLevel枚举来设置压缩级别,如`CompressionLevel.Fastest`(最快但压缩程度较低)或`CompressionLevel.Optimal`(较慢但压缩程度较高)。另外,通过实现IProgress更新&gt;接口,可以接收压缩进度回调...

    C#中的FFT算法

    FFTWSharp是基于FFTW(Fastest Fourier Transform in the West)的一个.NET封装,它提供了高效的单精度和双精度FFT算法。 1. **FFTWSharp库的引入** 在C#项目中使用FFTWSharp,首先需要下载并引用其源代码或NuGet...

    C# 压缩和解压

    DecompressSingleFile(file.FullName, Path.Combine(destinationFolderPath, file.Name.Replace(".gz", ""))); } } // 压缩单个文件 private static void CompressSingleFile(string sourceFilePath, string ...

    C#处理压缩文件代码

    2. **自定义压缩级别**:默认的压缩级别是`Optimal`,你可以通过`ZipArchiveEntry.CompressionLevel`属性设置压缩级别,如`NoCompression`、`Fastest`和`Optimal`。 3. **处理文件名编码**:ZIP文件可能包含非ASCII...

    Accelerated C# 2010

    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 ...

    Accelerated C# 2008

    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-...

    wp fastest cache Premium高级版

    **标题解析:** "wp fastest cache Premium高级版" 指的是WordPress中的一款高效缓存插件的高级版本。这款插件旨在优化网站性能,通过缓存机制减少页面加载时间,提升用户体验。 **描述详解:** 1. **WordPress缓存...

    wp-fastest-cache-premium-v1.5.7_cache_

    6. **去除Query String**:移除URL中的无用参数,减少对服务器的负担,提高缓存效率。 7. **内存缓存**:除了硬盘缓存,插件还提供内存缓存,利用服务器内存来加速动态内容的生成。 8. **白名单和黑名单**:允许...

    Accelerated C# 2005

    Youll also learn best practices that ensure your code will be efficient, reusable, and robust. &lt;br&gt;This book is the fastest path to C# mastery for anyone familiar with object-oriented programming....

    wp-fastest-cache-premium-1.5.8_WordPress_

    《WordPress优化神器:WP Fastest Cache Premium 1.5.8深度解析》 在WordPress的世界里,网站性能的优化是每个站点管理员关注的重点。而WP Fastest Cache Premium 1.5.8,作为一款强大的缓存插件,以其高效、易用的...

    Fastest way to build an HTML string(拼装html字符串的最快方法)

    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.4.9

    WP Fastest Cache Premium-WordPress静态缓存插件,官方原版无修改,须配合免费版使用(同时启用免费版及本专业版),免费版自行在wordpress-plugins搜索按照即可。 功能: 发布新文章会更新插件缓存文件 缓存文件...

    yolo-fastest-xl.cfg

    yolo-fastest-xl.cfg

    用opencv的dnn模块实现Yolo-Fastest的目标检测.zip

    用opencv的dnn模块实现Yolo-Fastest的目标检测.zip用opencv的dnn模块实现Yolo-Fastest的目标检测.zip用opencv的dnn模块实现Yolo-Fastest的目标检测.zip用opencv的dnn模块实现Yolo-Fastest的目标检测.zip用opencv的...

    Java Fastest String Utility-开源

    最快的字符串实用程序是用于字符串操作的Java库(JAR)。 该库在字符串操作(例如split,toUpperCase,toLowerCase,替换,删除,正则表达式等)中非常易于使用,非常快速且非常有效。

    YOLO-Fastest嵌入式部署开发环境配置流程1

    ### YOLO-Fastest嵌入式部署环境配置流程详解 #### 一、概述 YOLO-Fastest作为一款高效的目标检测模型,在嵌入式设备上的部署变得日益重要。其部署方式主要有两种:一是利用NCNN框架进行CPU推理;二是通过RK3399...

    Python for Programmers: with Big Data and Artificial Intelligence Case Studies

    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 ...

Global site tag (gtag.js) - Google Analytics