Created
May 29, 2015 19:37
-
-
Save JEG2/5510b82234e127d05c3a to your computer and use it in GitHub Desktop.
A manual `gsub!()`?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> 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