Skip to content

Instantly share code, notes, and snippets.

@KitaitiMakoto
Created March 12, 2012 11:46
Show Gist options
  • Save KitaitiMakoto/2021351 to your computer and use it in GitHub Desktop.
Save KitaitiMakoto/2021351 to your computer and use it in GitHub Desktop.
正規表現の中で名前付きグループの後方参照 ref: http://qiita.com/items/3144
# 文字列からクォートのペアを取り除く
re = /(?<quote>['"])(?<body>[^'"]*)\k<quote>/
puts "These are 'quotes'".gsub(re, '\k<body>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment