String#count options

前端 未结 6 747
Happy的楠姐
Happy的楠姐 2021-02-02 06:01

From the documentation for String#count I understand the first example, but I do not understand the rest of the examples:

a = \"hello world\"
a.count \"lo\"              


        
6条回答
  •  故里飘歌
    2021-02-02 06:28

    Using gsub in string

    a = "hello world hello hello hello hello world world world"
    2.1.5 :195 > a.gsub('hello').count
    => 5 
    

提交回复
热议问题