grep a block of code

M

Maciej Pindela

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
 
B

Bill Kelly

From: "Maciej Pindela said:
<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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top