Ahjesus singular-plural mutual conversion C #,
The built-in codesmith template converts the single and multiple numbers when generating the stored procedure, and implements
Public static class StringUtil {// <summary> // The word is in the singular form. /// </summary> /// <param name = "word"> </param> /// <returns> </returns> public static string ToSingular (string word) {Regex plural1 = new Regex ("(? <Keep> [^ aeiou]) ies $ "); Regex plural = new Regex ("(? <Keep> [aeiou] y) s $ "); Regex plur_3 = 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> /// the word is in the plural form. /// </summary> /// <param name = "word"> </param> // /<Returns> </returns> public static string ToPlural (string word) {Regex plural1 = new Regex ("(? <Keep> [^ aeiou]) y $ "); Regex plural = new Regex ("(? <Keep> [aeiou] y) $ "); Regex plur_3 = 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 ;}}
English words singular to plural
Generally add s. for example, run-runs. end with y as I plus es. for example, fly-flies. however, if y is preceded by a vowel, that is, aeiou. for example, add s directly, and end with f or fe. add. for example. knife-knives
Convert singular to plural form
Where is the word?