Ruby regexp detect CJK character #encoding: UTF-8 class String def contains_cjk? !!(self =~ /\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}/) end end strings= ['中国国際放送局', '광고 프로그램', '真是牛阿', 'This is english.'] strings.each{|s| puts s.contains_cjk?} Result will be: true true true false Published: March 01 2012 category: tags: Ruby 12 Related Posts • iOS ARC trap • Check how many client connected to your internet sharing on your mac • Prevent iCloud backup your downloadable content on iOS • Use bower in rails • jquery page scroll animation • How to solve the error: no decode delegate for this image format • Capistrano with bundler • New xcode uncomfortable things • Problem with carrierwave when you have two servers • use ActiveSupport::Configurable to store config options Tweet Please enable JavaScript to view the comments powered by Disqus. blog comments powered by Disqus