PerlとPHPを参考に。 こんな感じですかね。帰ってくる文字列はまだVodafone名ですが(Softbankに変更すべき?)。 class MobileDetect DocomoReg = %r VodafoneReg = %r<(?:(?:Softbank|Vodafone|J-PHONE)/\d\.\d|MOT-)> EzwebReg = %r<^(?:KDDI-[A-Z]+\d+[A-Z]? )?UP\.Browser\/> AirhReg = %r<^Mozilla/3\.0\*1> def self.detect(user_agent) if MobileReg =~ user_agent return 'DoCoMo' if $1 return 'Vodafone' if $2 return 'EZweb' if $3 return 'Airh' if $4 end ret