1. I was very excited when I first found a regular expression on the Internet!
Regular Expression
Public String makeplural (string name)
{
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 (name ))
Return plural1.replace (name, "$ {keep} ies ");
Else if (plural2.ismatch (name ))
Return plural2.replace (name, "$ {keep} s ");
Else if (plural3.ismatch (name ))
Return plural3.replace (name, "$ {keep} es ");
Else if (plural4.ismatch (name ))
Return plural4.replace (name, "$ {keep} s ");
Return name;
}
Public String makesingle (string name)
{< br> 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 (name ))
Return plural1.replace (name, "$ {keep} y ");
Else if (plural2.ismatch (name ))
Return plural2.replace (name, "$ {keep }");
Else if (plural3.ismatch (name ))
Return plural3.replace (name, "$ {keep }");
Else if (plural4.ismatch (name ))
Return plural4.replace (name, "$ {keep }");
Return name;
}
2. Then I found a better method in the instructor template.
Method in the template
code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/
--> Public String gettablename (tableschema table, bool plural)
{< br> string entityname = table. name;
If (plural)
{< br> entityname = stringutil. toplural (entityname);
}< br> else
{< br> entityname = stringutil. tosingular (entityname);
}< br>
return entityname;
}
3. modified the template http://www.namipan.com/downfile/Templates.rar/6a8380d9284d2b9d2b181a843c4a5053201d56079e550000 after the complex number