[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

grep a block of code

Maciej Pindela

5/7/2009 11:35:00 AM

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-....

2 Answers

Bill Kelly

5/7/2009 12:05:00 PM

0


From: "Maciej Pindela" <beny18241@gmail.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



Maciej Pindela

5/8/2009 9:00:00 AM

0

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-....