Skip to content

Instantly share code, notes, and snippets.

@longlostnick
Created December 18, 2012 21:15
Show Gist options
  • Select an option

  • Save longlostnick/4332079 to your computer and use it in GitHub Desktop.

Select an option

Save longlostnick/4332079 to your computer and use it in GitHub Desktop.
Find and replace using split and join.
string = "this is cool"
"*#{string}*".split("cool").join("dumb")[1..-2]
# => "this is dumb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment