Skip to content

Instantly share code, notes, and snippets.

@JEG2
Created May 29, 2015 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JEG2/5510b82234e127d05c3a to your computer and use it in GitHub Desktop.
Save JEG2/5510b82234e127d05c3a to your computer and use it in GitHub Desktop.
A manual `gsub!()`?
>> s = "active_model/errors"
=> "active_model/errors"
>> i = 0
=> 0
>> while (md = s.match(/(?:_|(\/))([a-z\d]*)/i, i)); s[md.begin(0)...md.end(0)] = "#{md[1]}#{md[2].capitalize}"; i = md.end(0) - 1 end
=> nil
>> s
=> "activeModel/Errors"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment