判断 拼音的正则

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#区分拼音和英文的代码

#拼音正则1

R = /(b|p|m|f|d|t|n|l|g|k|h|j|q|x|zh|ch|sh|r|z|c|s|y|w)(a|o|e|i|u|ao|iu|ei|ui|ou|iu|ie|an|en|in|un|ang|eng|ing|ong)/i
class String
  def is_py
    self.match(/^(#{R}\s?)+$/)
  end
end
    
s=[]
s << 'wo shi ji qi ren'
s << 'zheshi pinyin'
s << 'show me the money'
s << 'this is english '

s.each{|x| print x, " : " , x.is_py ? 'y':'n', "\n" }


#wo shi ji qi ren : y
#zheshi pinyin : y
#show me the money : n
#this is english  : n