Skip to content

Instantly share code, notes, and snippets.

@HammerInTheNews
Created December 13, 2013 20:29
Show Gist options
  • Select an option

  • Save HammerInTheNews/7950854 to your computer and use it in GitHub Desktop.

Select an option

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