method

count

v1_8_6_287 - Show latest stable - Class: String
count(...)
public

Each other_str parameter defines a set of characters to count. The intersection of these sets defines the characters to count in str. Any other_str that starts with a caret (^) is negated. The sequence c1—c2 means all characters between c1 and c2.

   a = "hello world"
   a.count "lo"            #=> 5
   a.count "lo", "o"       #=> 2
   a.count "hello", "^l"   #=> 4
   a.count "ej-m"          #=> 4