Ahjesus singular-plural mutual conversion C #,

Source: Internet
Author: User

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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.