fv17の日記

Webエンジニアの備忘用ブログです。主にWeb界隈の技術に関して書いています。

Rubyのsub, gsubは何の略か?

気になって仕方がないので調べてみました。

挙動の確認

string = "One tomato, two tomato, three tomato."
string.sub('tomato','banana') # => "One banana, two tomato, three tomato."
string.gsub('tomato','banana') # => "One banana, two banana, three banana."


subは何の略語?

substitution / 置換

gsubは何の略語?

global substitution / グローバル置換


注:groupという説もありますが、vimwikiではgsubは上記のように記述。