Logan Capaldo
2/7/2006 7:14:00 PM
On Feb 7, 2006, at 9:30 AM, James Edward Gray II wrote:
> On Feb 7, 2006, at 7:08 AM, ralf wrote:
>
>> I'd like to have a "grep" with case-insensitive match.
>
> You can turn options on/off inside a pattern. For example, here is
> a pattern that matches the word file, regardless of case:
>
> (?i:file)
>
>> Maybe this can be done a lot easier by using ARGF??
>
> Yes it can. Your input loop can be replaced with:
>
> ARGF.grep(pattern) do |line|
> puts "#{ARGF.filename} #{ARGF.lineno}: #{line}"
> end
>
> Hope that helps.
>
> James Edward Gray II
>
>
Minor suggestion, line is going to end in an nl anyway. I would use
print, unless you want all that extra whitespace in the output.