Skip to content

Instantly share code, notes, and snippets.

@vargheseraphy
Last active August 29, 2015 14:15
Show Gist options
  • Save vargheseraphy/82d705f781c369aa95e8 to your computer and use it in GitHub Desktop.
Save vargheseraphy/82d705f781c369aa95e8 to your computer and use it in GitHub Desktop.
"hello".gsub(/[aeiou]/, '*') #=> "h*ll*"
"hello".gsub(/([aeiou])/, '<\1>') #=> "h<e>ll<o>"
"hello".gsub(/./) {|s| s.ord.to_s + ' '} #=> "104 101 108 108 111 "
"hello".gsub(/(?<foo>[aeiou])/, '{\k<foo>}') #=> "h{e}ll{o}"
'hello'.gsub(/[eo]/, 'e' => 3, 'o' => '*') #=> "h3ll*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment