Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Created March 3, 2012 14:51
Show Gist options
  • Select an option

  • Save daviddavis/1966515 to your computer and use it in GitHub Desktop.

Select an option

Save daviddavis/1966515 to your computer and use it in GitHub Desktop.
code = "__ == __ == Date.parse(date.sub(/(\d+)[-\/](\d\d).(\d{4})/,'\\3-\\1-\\2')).strftime('%b %d, %Y')"
sub = "Date.parse(date.sub(/(\d+)[-\/](\d\d).(\d{4})/,'\\3-\\1-\\2')).strftime('%b %d, %Y')"
code.gsub("__", sub) # Date.parse(date.sub(/(d+)[-/](dd).(d{4})/,'--'))...
code["__"] = sub # only fill in one at a time. fails when sub = "__method__"
code.split("__").join(sub) # ugly but seems to work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment