以下の内容はhttps://tbpgr.hatenablog.com/entry/20120529/1338309910より取得しました。


書籍 Regular Expressions Cookbook | Replace All Matches Within the Matches of Another Regex

パンくず

書籍 Regular Expressions Cookbook
Replace All Matches Within the Matches of Another Regex

概要

正規表現で抽出した内容のうち、
更に別の正規表現に一致するもののみ置換する

サンプル

# タグの中の文字列がbeforeだった場合のみ置換する
subject = "<b>before</b>"
innerre = /before/
result = subject.gsub(/<b>.*?<\/b>/) {|match|
    match.gsub(innerre, 'after')
}
pp result #=>"<b>after</b>"



以上の内容はhttps://tbpgr.hatenablog.com/entry/20120529/1338309910より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14