版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
版权
php专栏收录该内容
30 篇文章0 订阅
订阅专栏
public function pluralize($name) { $rules=array( '/move$/i' => 'moves', '/foot$/i' => 'feet', '/child$/i' => 'children', '/human$/i' => 'humans', '/man$/i' => 'men', '/tooth$/i' => 'teeth', '/person$/i' => 'people', '/([m|l])ouse$/i' => '\1ice', '/(x|ch|ss|sh|us|as|is|os)$/i' => '\1es', '/([^aeiouy]|qu)y$/i' => '\1ies', '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', '/(shea|lea|loa|thie)f$/i' => '\1ves', '/([ti])um$/i' => '\1a', '/(tomat|potat|ech|her|vet)o$/i' => '\1oes', '/(bu)s$/i' => '\1ses', '/(ax|test)is$/i' => '\1es', '/s$/' => 's', ); foreach($rules as $rule=>$replacement) { if(preg_match($rule,$name)) return preg_replace($rule,$replacement,$name); } return $name.'s'; }
收藏
一键三连
扫一扫,分享海报
专栏目录
def plural(word): if word.endswith('y'): return word[:-1]+'ies' elif word[-1] in 'sx' or word[-2:] in ['sh','ch']: return word+'es' elif word.endwith('an'): return
1.1 名词复数的规则变化 1.一般情况 加-s 清辅音后读/s/ map-maps 浊辅音和元音后读 /z/ bag-bags /car-cars 2. 以s, sh, ch, x等结尾 加-es 读...
function Complex(R , I){ if( isNaN( R ) || isNaN( I )) { throw new TypeError('Complex params require Number'); } this.r = R; this.i = I; } // 加...