generated at
文字列中の任意の文字の数を調べる
ruby
s = "hello, world" puts s.count("l") #=> 3 # 下の例はlとoの数を調べる s = "hello, world" puts s.count("lo") #=> 5 # 下の例は小文字のアルファベットかつoでない文字も数を調べる # 複数の引数を指定すると、「かつ」の関係になる s = "hello, world" puts s.count("a-z", "^o")


? Ruby: 文字列中の任意の文字の数を調べる