http://www.codewars.com/kata/55c423ecf847fbcba100002b/train/csharp

Oh no, Timmy's received some hate mail recently but he knows better. Help timmy fix his regex filter so he can be awesome again!

using System;
using NUnit.Framework;
System.Text.RegularExpressions [TestFixture]
public class Tests
{
[Test]
public static void FixedTest()
{
Assert.AreEqual("You're awesome! timmy!", Kata.filterWords("You're Bad! timmy!"));
Assert.AreEqual("You're awesome! timmy!", Kata.filterWords("You're MEAN! timmy!"));
Assert.AreEqual("You're awesome!! timmy!", Kata.filterWords("You're UGLY!! timmy!"));
Assert.AreEqual("You're awesome! timmy!", Kata.filterWords("You're horrible! timmy!"));
Assert.AreEqual("You're awesome!! timmy!", Kata.filterWords("You're HiDeOuS!! timmy!"));
Assert.AreEqual("You're awesomeish!! timmy!", Kata.filterWords("You're Meanish!! timmy!"));
}
}

主要是i的用法,

i

Use case-insensitive matching.

\b(?i)a(?-i)a\w+\b

"aardvark", "aaaAuto" in "aardvark AAAuto aaaAuto Adam breakfast"

using System;
using System.Text.RegularExpressions; public class Kata
{
public static string filterWords(string phrase)
{
string pattern = @"(?i)bad|mean|ugly|horrible|hideous\b";
string replacement = "awesome";
Regex rgx = new Regex(pattern);
return rgx.Replace(phrase, replacement);
}
}

Regex Failure - Bug Fixing #2的更多相关文章

  1. 【JMeter】if语句中不能Failure=false解决办法

    错误写法: if(roomId.matches("regEx")) Failure=false; else{ Failure=true; FailureMessage=" ...

  2. 10个JavaScript常见BUG及修复方法

    译者按: JavaScript语言设计太灵活,用起来不免要多加小心掉进坑里面. 原文: Top 10 bugs and their bug fixing 译者: Fundebug 为了保证可读性,本文 ...

  3. 【转】IE浏览器CSS BUG集锦

    Internet Explorer CSS Bugs Overview Internet Explorer is famous for not supporting many of CSS prope ...

  4. Percona Server 5.6.33-79.0 发布

    Percona Server 5.6.33-79.0 发布了,该版本基于 MySQL 5.6.33,包含了所有的 bug 修复,是Percona Server 5.6 系列中的正式版本.该版本主要是修 ...

  5. iOS之应用版本号的设置规则

    版本号的格式:v<主版本号>.<副版本号>.<发布号>  版本号的初始值:v1.0.0 管理规则: 主版本号(Major version) 1.  产品的主体构件进 ...

  6. TDD学习笔记【二】---单元测试简介

    大纲 Testing 的第一个切入点:单元测试. 本篇文章将针对单元测试进行简介,主要内容包含了5W: Why What Where Who When 而How 的部分,属于实现部分,将于下一篇文章介 ...

  7. 【Basics of Entity Framework】【EF基础系列1】

    EF自己包括看视频,看MSDN零零散散的学了一点皮毛,这次打算系统学习一下EF.我将会使用VS2012来学习这个EF基础系列. 现在看看EF的历史吧: EF版本 相关版本特性介绍 EF3.5 基于数据 ...

  8. EntityFramework Core技术线路(EF7已经更名为EF Core,并于2016年6月底发布)

    官方文档英文地址:https://github.com/aspnet/EntityFramework/wiki/Roadmap 历经延期和更名,新版本的实体框架终于要和大家见面了,虽然还有点害羞.请大 ...

  9. What technical details should a programmer of a web application consider before making the site public?

    What things should a programmer implementing the technical details of a web application consider bef ...

随机推荐

  1. C++实现数字媒体三维图像渲染

    C++实现数字媒体三维图像渲染 必备环境 glut.h 头文件 glut32.lib 对象文件库 glut32.dll 动态连接库 程序说明 C++实现了用glut画物体对象的功能.并附带放大缩小,旋 ...

  2. sql Mirroring

    http://www.codeproject.com/Articles/109236/Mirroring-a-SQL-Server-Database-is-not-as-hard-as http:// ...

  3. redhat或centos关闭防火墙并开启sshd服务

    使用putty连接虚拟机的redhat连不上时处理方案: 这里使用的是VMware Workstation,  将宿主机与虚拟机之间的网络使用 ‘桥接方式’: 1.关闭宿主机与虚拟机的防火墙, 在re ...

  4. 日志文件切割服务logrotate配置及crontab定时任务的使用

    1.下载logrotate 在Fedora和CentOS安装 yum install logrotate crontabs Debian和Ubuntu上 apt-get install logrota ...

  5. python 笔记总结

    python  3.5 面向对象:类:具有同种属性的对象称为类,是个抽象的概念.比如说:汽车.人.狗.神:对象:日常生活中的所有东西都是对象,是类的实例化.比如说:推土车是汽车的实例化:姚明是人的实例 ...

  6. ASP.NET Web – AJAX 回送

    使用UpdatePanel时要一起使用的控件是ScriptManager.ScriptManager类加载了包含几个功能的JavaScript函数.也可以使用这个类加载自己定制脚本.ScriptMan ...

  7. 【经验】Angularjs 中使用 layDate 日期控件

    layDate 控件地址:http://laydate.layui.com/ 前情:原来系统中使用的日期控件是UI bootstrap(地址:https://angular-ui.github.io/ ...

  8. HDU 4587 TWO NODES 割点

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4587 题意: 删除两个点,使连通块的数目最大化 题解: 枚举删除第一个点,然后对删除了第一个点的图跑 ...

  9. 【BZOJ】【1532】【POI2005】Kos-Dicing

    网络流/二分法 最大值最小……直接做不太好做的时候就可以用二分+判定来搞. 这题我们就也可以二分最大胜场v,那么怎么来判定呢?首先我们发现:每场比赛要么A赢,要么B赢,这一点跟二分图匹配非常类似,那么 ...

  10. error: The shader requires a sampler in slot 0 which hasn't been set [XXXsampler]

    About the sampler, you need to assign it to your pixelshader. m_d3dContext.Get()->PSSetSamplers(0 ...