Skip to content

Instantly share code, notes, and snippets.

@SeanPlusPlus
Created October 6, 2011 19:47
Show Gist options
  • Save SeanPlusPlus/1268441 to your computer and use it in GitHub Desktop.
Save SeanPlusPlus/1268441 to your computer and use it in GitHub Desktop.
Add White Space Before Caps
$ cat myOldFile
HelloJesseAndGlen
IHopeThatYouAreChillin
$ irb
>> myNewFile = File.open('myNewFile', 'w')
=> #<File:myNewFile>
>> File.open('myOldFile').each { |line|
?> myNewFile.puts line.scan(/[A-Z][a-z]+/) * " "
>> }
=> #<File:myOldFile>
>> myNewFile.close
=> nil
>> exit
$ cat myNewFile
Hello Jesse And Glen
Hope That You Are Chillin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment