Skip to content

Instantly share code, notes, and snippets.

@SeanPlusPlus
Created October 7, 2011 01:32
Show Gist options
  • Save SeanPlusPlus/1269223 to your computer and use it in GitHub Desktop.
Save SeanPlusPlus/1269223 to your computer and use it in GitHub Desktop.
Cap Parser
#!/usr/bin/ruby
myNewFile = File.open('myNewFile', 'w')
File.open(ARGV[0]).each do |line|
i = 0
line.each_byte do |c|
while i < line.length
if (line[i] =~ /[A-Z]/) and ((line[i-1] =~ /[a-z]/) or (line[i-1] =~ /[,.:;!?]/))
myNewFile.printf " %c", line[i]
else
myNewFile.printf"%c", line[i]
end
i += 1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment