I have been trying to filter some text from a file to only show certain years of birth
I have some ruby that reads in a file ages.txt, it contains names and years of birth
- Joe Bloggs (2001)
- Mary Bloggs (1987)
- John apples (2010)
- Old Guy (1990)
I wish to be able to filter for a year range, i.e. to find people born between 1987 and 1990
I have tried
#open('ages.txt') { |f| f.grep(/^19(8[0-9]|10)$/) }
but I get an error
ages.rb:3:in `===': invalid byte sequence in UTF-8 (ArgumentError)
Any help would be greatfull.