Grep a block of code

Hi

Lately someone gave me a task, to grep from csv file but a block of
code.
How to do it ?

for example

<tag>
2
3
4
5
</tag>

How to use grep to give me all form file wich start with <tag> and end
with </tag>

I've tried that way..

puts File.readlines(ARGV[0]).grep(/<tag> * <\/tag>/)

Please help

···

--
Posted via http://www.ruby-forum.com/.

<tag>
2
3
4
5
</tag>

How to use grep to give me all form file wich start with <tag> and end
with </tag>

I've tried that way..

puts File.readlines(ARGV[0]).grep(/<tag> * <\/tag>/)

puts ARGF.read.scan(/<tag>.*?<\/tag>/m)

Regards,

Bill

···

From: "Maciej Pindela" <beny18241@gmail.com>

Bill Kelly wrote:

From: "Maciej Pindela" <beny18241@gmail.com>

I've tried that way..

puts File.readlines(ARGV[0]).grep(/<tag> * <\/tag>/)

puts ARGF.read.scan(/<tag>.*?<\/tag>/m)

Regards,

Bill

Thanks that's works

···

--
Posted via http://www.ruby-forum.com/\.