るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.016秒)
トップページ > クラス:String[x] > クエリ:match[x] > クエリ:gsub![x]

別のキーワード

  1. _builtin match
  2. _builtin match?
  3. string match
  4. regexp match
  5. regexp last_match

ライブラリ

検索結果

String#gsub!(pattern) {|matched| .... } -> self | nil (18202.0)

文字列中で pattern にマッチする部分全てを順番にブロックに渡し、 その評価結果に置き換えます。

...は全く同じ文字列にだけマッチする
@return 置換した場合は self、置換しなかった場合は nil

//emlist[例][ruby]{
str = 'abcabc'
str.gsub!(/b/) {|s| s.upcase }
p str #=> "aBcaBc"

str = 'abcabc'
str.gsub!(/b/) { $&.upcase }
p str #=> "aBcaBc"
//}

@see String#sub...