I’m fairly new to programming with regular expressions. I would like
some help with the
following. Consider the format given below as what I will receive in a
file.
While reading from the file, Im interested only in reading those lines
that have the forward-slash’ in
them (lines 9,10,12, 13). How can I do this in ruby?
I’m fairly new to programming with regular expressions. I would like
some help with the
following. Consider the format given below as what I will receive in a
file.
While reading from the file, Im interested only in reading those lines
that have the forward-slash’ in
them (lines 9,10,12, 13). How can I do this in ruby?
(…)
You don’t need a regular expression for this. To select the lines which
include a slash, you can do
block is true in an array.
Siep, I can’t find any documentation on File#select, and IO#select is
not
documented as doing what you show. Could you provide more info about it?
While reading from the file, Im interested only in reading those lines
that have the forward-slash’ in
them (lines 9,10,12, 13). How can I do this in ruby?
Returns an array containing all elements of enum for which block
is not false (see also Enumerable#reject).
(1..10).find_all {|i| i % 3 == 0 } #=> [3, 6, 9]