Replace #inject with #reduce
Remove extra empty lines
Correcting indentation
Append rubocop to list of tasks run by rake
Use string literal, not character literal
Avoid the use of Perl-style backrefs

Refactor to use capture groups as they are more meaningful.