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 ...
随机推荐
- Entity Framework(一) 映射
ADO.NET Entity Framework通过Modeel First和DataBase First,提供了几个把数据库表映射到对象上的曾.通过Database First,可以从一个数据库架构 ...
- POJ 1195 2维线段树(树套树实现) 树状数组
1: #include <stdio.h> 2: #include <string.h> 3: #include <stdlib.h> 4: #include &l ...
- Python Socket File Transfer
I have a RPi which I intented to use it to crawl data. The development environment in RPi is very ba ...
- ios 多任务学习笔记
一.检测多任务是否支持: - (BOOL) isMultitaskingSupported{ BOOL result = NO; if ([[UIDevice currentDevice] respo ...
- Codeforces Round #360 (Div. 2) E. The Values You Can Make 01背包
题目链接: 题目 E. The Values You Can Make time limit per test:2 seconds memory limit per test:256 megabyte ...
- oracle将两个结果连接后进行查询,得到两个查询的联合结果
一.需求 用户答题,共3道,必须3题都答完才能提交. 目的:要查询用户答对了几题,答错了几题.(当然此处可以只查答对的题目数,用3减即得答错题的题目数) 二.sql select * ) rightC ...
- uva 12086 树状数组
树状数组 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> #i ...
- SDUT1479数据结构实验之栈:行编辑器
先是普通的数组做法 #include<stdio.h> #include<string.h> int main() { ] ; while(~scanf("%s&qu ...
- POJ1046Color Me Less
http://poj.org/problem?id=1046 据说这个题是个水题,但我还是WA了好几次,最后才改对了 #include<cstdio> #include<cstrin ...
- lintcode :搜索二维矩阵
题目: 搜索二维矩阵 写出一个高效的算法来搜索 m × n矩阵中的值. 这个矩阵具有以下特性: 每行中的整数从左到右是排序的. 每行的第一个数大于上一行的最后一个整数. 样例 考虑下列矩阵: [ [1 ...