-
-
Save xcobar/400989355ae2e5b0068d0b0561c9f6c6 to your computer and use it in GitHub Desktop.
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
lines = File.readlines('file.rb') | |
File.open('file.rb', 'r+') do |f| | |
f.each_line do |line| | |
if line.start_with?('dog', 'cat') | |
line.gsub!(/food/, '') | |
end | |
end | |
end | |
# example this should become | |
# cat's are really nice sometimes, we give them good cat food. | |
# dog's are nice too | |
# should become | |
# cat's are really nice sometimes, we give them good cat . | |
# dog's are nice too | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment