class ConvJaChar::CharTypeCheck

Public Class Methods

kanji?(str) click to toggle source
# File lib/conv_ja_char/check_char.rb, line 7
def self.kanji?(str)
  return nil unless str

  regexp_kanji = /[一-龠々]+/

  str =~ regexp_kanji # nil: not match, not nil: the position number that the matched char starts
end
symbol?(str) click to toggle source
# File lib/conv_ja_char/check_char.rb, line 15
def self.symbol?(str)
  return nil unless str

  regexp_symbol = /[!"#%&()*+,.\/:;<=>?@^_`{|}~]+/ # without white space, dollar sign($), single quotation(') and hyphen(-)

  str =~ regexp_symbol # nil: not match, not nil: the position number that the matched char starts
end