Sha256: d655979ebf5236b879116f0e18ff68579bf83a9ca06258d58722f873b181b222

Contents?: true

Size: 598 Bytes

Versions: 1

Compression:

Stored size: 598 Bytes

Contents

# encoding: utf-8

require 'conv_ja_char/version'

module ConvJaChar
  class CharTypeCheck
    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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conv_ja_char-0.0.1 lib/conv_ja_char/check_char.rb