国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ahjesus 單詞單數-復數相互轉換C#

2019-11-17 03:01:24
字體:
來源:轉載
供稿:網友

ahjesus 單詞單數-復數相互轉換C#

看codesmith內置的模板在生成存儲過程的時候有單復數的轉換,用相同的函數名實現了一個
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;        }    }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阳城县| 浪卡子县| 叙永县| 军事| 望谟县| 康马县| 民县| 磐石市| 广灵县| 洞头县| 高唐县| 富蕴县| 延庆县| 吴堡县| 宁远县| 浮梁县| 玉环县| 福建省| 高邮市| 新沂市| 桦南县| 常山县| 靖州| 神池县| 芜湖县| 沾化县| 天台县| 宜都市| 冕宁县| 雷波县| 武宁县| 新绛县| 临洮县| 湖南省| 南京市| 城步| 奈曼旗| 汤原县| 信丰县| 桂阳县| 台前县|