Created
December 13, 2013 20:29
-
-
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.
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.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