Regex Failure - Bug Fixing #2
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的更多相关文章
- 【JMeter】if语句中不能Failure=false解决办法
错误写法: if(roomId.matches("regEx")) Failure=false; else{ Failure=true; FailureMessage=" ...
- 10个JavaScript常见BUG及修复方法
译者按: JavaScript语言设计太灵活,用起来不免要多加小心掉进坑里面. 原文: Top 10 bugs and their bug fixing 译者: Fundebug 为了保证可读性,本文 ...
- 【转】IE浏览器CSS BUG集锦
Internet Explorer CSS Bugs Overview Internet Explorer is famous for not supporting many of CSS prope ...
- Percona Server 5.6.33-79.0 发布
Percona Server 5.6.33-79.0 发布了,该版本基于 MySQL 5.6.33,包含了所有的 bug 修复,是Percona Server 5.6 系列中的正式版本.该版本主要是修 ...
- iOS之应用版本号的设置规则
版本号的格式:v<主版本号>.<副版本号>.<发布号> 版本号的初始值:v1.0.0 管理规则: 主版本号(Major version) 1. 产品的主体构件进 ...
- TDD学习笔记【二】---单元测试简介
大纲 Testing 的第一个切入点:单元测试. 本篇文章将针对单元测试进行简介,主要内容包含了5W: Why What Where Who When 而How 的部分,属于实现部分,将于下一篇文章介 ...
- 【Basics of Entity Framework】【EF基础系列1】
EF自己包括看视频,看MSDN零零散散的学了一点皮毛,这次打算系统学习一下EF.我将会使用VS2012来学习这个EF基础系列. 现在看看EF的历史吧: EF版本 相关版本特性介绍 EF3.5 基于数据 ...
- EntityFramework Core技术线路(EF7已经更名为EF Core,并于2016年6月底发布)
官方文档英文地址:https://github.com/aspnet/EntityFramework/wiki/Roadmap 历经延期和更名,新版本的实体框架终于要和大家见面了,虽然还有点害羞.请大 ...
- 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 ...
随机推荐
- 命令行插入含有中文的sql文件,报错ERROR 1366 (HY000): Incorrect stringvalue:
--以下是插入语句: insert into sms_inbox values('123456','123456', 'cd', sysdate(), '今天天 气很好', 1, sysdate(), ...
- mysql日志文件
mysql的数据文件夹里出现mysql-bin日志文件,通过my.cnf注释掉log后,是否可以删除了? 参考 http://database.51cto.com/art/201107/278988. ...
- KAFKA分布式消息系统
2015-01-05 大数据平台 Hadoop大数据平台 基本概念 kafka的工作方式和其他MQ基本相同,只是在一些名词命名上有些不同.为了更好的讨论,这里对这些名词做简单解释.通过这些解释应该可以 ...
- Fibonacci数
Fibonacci数 时间限制:3000 ms | 内存限制:65535 KB 难度:1 描述 无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递 ...
- VS2013中设置大小写的快捷键
1.我们在定义头文件时,通常需要定义: #ifndef _MainMenu_H_#define _MainMenu_H_ your code... #endif 我们需要将头文件名设置为大写的: ...
- 3243: [Noi2013]向量内积 - BZOJ
Description 两个d 维向量A=[a1,a2,...,ad]与B=[b1,b2,...,bd]的内积为其相对应维度的权值的乘积和,即: 现有 n 个d 维向量x1,...,xn ,小喵喵想知 ...
- NuGet使用简要说明
引言 什么是NuGet?Nuget是 ASP .NET Gallery 的一员.NuGet 是免费.开源的包管理开发工具,专注于在 .NET 应用开发过程中,简单地合并第三方的组件库.当需要分享开发的 ...
- 01-04-01【Nhibernate (版本3.3.1.4000) 出入江湖】原生的SQL查询
Nhibernate 支持原生的SQL查询 : /// <summary> /// 使用原生的SQL查询 /// </summary> /// <param name=& ...
- UVALive 6533
哈夫曼树 倒过来思考 ~ 最深的叶子 值为1 所以最深的先出队列 #include <iostream> #include <cstdio> #include <cs ...
- How to define Servlet filter order of execution using annotations
If we define Servlet filters in web.xml, then the order of execution of the filters will be the same ...