Skip to content

Instantly share code, notes, and snippets.

@HammerInTheNews
Created December 13, 2013 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HammerInTheNews/7950854 to your computer and use it in GitHub Desktop.
Save HammerInTheNews/7950854 to your computer and use it in GitHub Desktop.
Read all the lines of a text file into an array if they match a certain pattern.
lines = File.new('foo.txt', 'r').select do |line|
line =~ /pattern/
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment