ahjesus 单词单数-复数相互转换C#
public static class StringUtil
{
/// <summary>
/// 单词变成单数形式
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string ToSingular(string word)
{
Regex plural1 = new Regex("(?<keep>[^aeiou])ies$");
Regex plural2 = new Regex("(?<keep>[aeiou]y)s$");
Regex plural3 = new Regex("(?<keep>[sxzh])es$");
Regex plural4 = new Regex("(?<keep>[^sxzhyu])s$"); if (plural1.IsMatch(word))
return plural1.Replace(word, "${keep}y");
else if (plural2.IsMatch(word))
return plural2.Replace(word, "${keep}");
else if (plural3.IsMatch(word))
return plural3.Replace(word, "${keep}");
else if (plural4.IsMatch(word))
return plural4.Replace(word, "${keep}"); return word;
}
/// <summary>
/// 单词变成复数形式
/// </summary>
/// <param name="word"></param>
/// <returns></returns>
public static string ToPlural(string word)
{
Regex plural1 = new Regex("(?<keep>[^aeiou])y$");
Regex plural2 = new Regex("(?<keep>[aeiou]y)$");
Regex plural3 = new Regex("(?<keep>[sxzh])$");
Regex plural4 = new Regex("(?<keep>[^sxzhy])$"); if (plural1.IsMatch(word))
return plural1.Replace(word, "${keep}ies");
else if (plural2.IsMatch(word))
return plural2.Replace(word, "${keep}s");
else if (plural3.IsMatch(word))
return plural3.Replace(word, "${keep}es");
else if (plural4.IsMatch(word))
return plural4.Replace(word, "${keep}s"); return word;
}
}
ahjesus 单词单数-复数相互转换C#的更多相关文章
- rails 单数 复数 大写 小写转换 下划线 驼峰命名
downcase 变小写 pluralize 复数 singularize 单数 camelcase 驼峰 underscore : “MyScore”.undersocre ==> my_s ...
- 【English】三、以o结尾单词变复数
一.以O结尾的词,许多加es构成复数,特别是一些常用词如: potatoes 土豆 tomatoes 西红柿 echoes 回声 tornadoes 龙卷风 torpedoes ...
- SQL表名,应该用复数还是单数
用单数形式更佳,理由如下: 1.概念直观. 你有一个袋子,里面有好多个苹果,你会说这是个苹果袋.但无论里面有0,1,百万个苹果,它依然是个袋子.表也是如此,表明需要描述清楚,表里面包含的对象,而非有多 ...
- SQL表名,应该用表对应资源对象的复数形式还是单数形式
原文:http://blog.csdn.net/lizeyang 问题 SQL表名,应该用表对应资源对象的复数形式还是单数形式.例如一个用户表,表名是用user还是users更合适呢? 精华回答 ...
- HDOJ/HDU 1804 Deli Deli(英语单词复数形式~)
Problem Description Mrs. Deli is running the delicatessen store "Deli Deli". Last year Mrs ...
- Atitit. . 软件命名空间与类名命名单词的统计程序设计v2
Atitit. . 软件命名空间与类名命名单词的统计程序设计v2 1. 要实现的目标1 1.1. Camel字符串模式的分词处理1 1.2. 多个大写的处理1 1.3. 数字与字幕的分离1 1.4. ...
- C++实现对文件中各单词词频的统计及其代码优化
先给出github上的代码链接以及项目需求 1.项目概述 这个项目的需求可以概括为:对记事本(txt)文件进行单词的词频统计和排序,排序结果以指定格式输出到默认文件中,并要求能够快速地完成整个统计和结 ...
- photo的复数是photos
以O结尾的单词变复数时,有生命的加es,无生命的加s. 如:photo,zoo,为无生命的,+s tomato,potato为有生命的,+es. 自己总结的,但到目前为止还没有遇到过例外的.记住这一个 ...
- Python3中文教程
搜索 此文档来源自网络 安装 PYTHON❝ Tempora mutantur nos et mutamur in illis. (时光流转,吾等亦随之而变.) ❞ — 古罗马谚语 深入欢迎来到 Py ...
随机推荐
- js获取当前时间显示在页面上
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- 锋利的jQuery——19个jQuery 常用片段整理
/** * Created by yu on 2016/11/20 0020. */// 1.禁用页面右键菜单$(function () { $(document).on('contextmenu', ...
- CSS3的学习--实现瀑布流
基于CSS3实现瀑布流,使用CSS3的CSS 多栏(Multi-column). 可以到github上下载源码 : https://github.com/CraryPrimitiveMan/water ...
- 《Selenium2自动化测试实战--基于Python语言》 --即将面市
发展历程: <selenium_webdriver(python)第一版> 将本博客中的这个系列整理为pdf文档,免费. <selenium_webdriver(python)第 ...
- 在Python中实现PageFactory模式
关于 PageFactory 的概念主要是Java中内置了PageFactory类. import org.openqa.selenium.support.PageFactory; …… 例子,htt ...
- JavaScript中以一个方法作为参数的写法
前言,我们写js的时候,经常会看到一些方法,比如说: $("#ids").click(function( alert("Click me"); )); ---- ...
- 谷歌插件Image downloader开发之 content script
自己运营了一个公众号,在发文章的时候,需要在网上找一些图,而有些网站的图片可能隐藏在属性或者背景图中,要下载的时候经常审查元素,查看源码,不太方便,最近在看一些谷歌插件的api,便顺手做了一个插件Im ...
- JS&CSS文件请求合并及压缩处理研究(五)
接上篇.在我们最终调用 @Html.RenderResFile(ResourceType.Script) 或者 @Html.RenderResFile(ResourceType.StyleSheet) ...
- Elasticsearch——使用_cat查看Elasticsearch状态
Elasticsearch通过使用JSON来作为沟通的数据格式,这对于开发者来说很友好,因为很多程序都支持JSON格式.比如js就不说了,Java也有fastjson,ruby什么的都自带json. ...
- Struts2 源码分析——过滤器(Filter)
章节简言 上一章笔者试着建一个Hello world的例子.是一个空白的struts2例子.明白了运行struts2至少需要用到哪一些Jar包.而这一章笔者将根据前面章节(Struts2 源码分析—— ...