[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: [NEWBIE] Extract all occurences from a text
From:       Michael Weller <michael () gutschi ! de>
Date:       2004-04-23 11:42:08
Message-ID: 40890152.1080104 () gutschi ! de
[Download RAW message or body]

Thanks for your responses! I knew there must be a simple way...
(actually the pattern is a bit different, I just wrote an example 
pattern without testing!)

Michael

gabriele renzi wrote:

>il Fri, 23 Apr 2004 19:53:43 +0900, Michael Weller
><michael@gutschi.de> ha scritto::
>
>  
>
>>Hi!
>>I just can't figure out how to extract all matches from a text file.
>>I have a file that looks like this:
>>...
>><h1>some text i don't want</h1>
>><a href="/2004/04/21">Data from 21.4.2004</a><br>
>><a href="/2004/04/22">Data from 22.4.2004</a><br>
>>...
>>I have a pattern /\d{4,}/\\d{2,}/\\d{2,}/ which matches everything in 
>>the links' target, but I don't want just the first match or the last 
>>one... I searched google and looked in "programming ruby" but couldn't 
>>find a solution...
>>If you know how this works, please tell me!
>>    
>>
>
>you could simply do:
>
>lines=[]
>open(filename) do |f|
> lines= f.grep your_regexp
>end
>
>even if Actually your regexp does not makes sens to me. 
>I believe you want dates, so it should be
> /\d{4}\/\d{2}\/\d{2}/
>it seem you escaped wrong characters ( \ instead of / )
>
>
>  
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic