From ruby-talk Fri Apr 23 11:00:01 2004 From: Emmanuel Touzery Date: Fri, 23 Apr 2004 11:00:01 +0000 To: ruby-talk Subject: Re: [NEWBIE] Extract all occurences from a text Message-Id: <4088F7B5.2010105 () wanadoo ! fr> X-MARC-Message: https://marc.info/?l=ruby-talk&m=108271803415797 Michael Weller wrote: > Hi! > I just can't figure out how to extract all matches from a text file. > I have a file that looks like this: > .... >

some text i don't want

> Data from 21.4.2004
> Data from 22.4.2004
> .... > 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! > > Thanks in advance! File.open('filename').read().scan /\d{4,}/\\d{2,}/\\d{2,}/ should return the array of matches. emmanuel