From: Axel Etzold Date: 2008-09-08T04:20:47+09:00 Subject: Re: regular expression match and exclude -------- Original-Nachricht -------- > Datum: Mon, 8 Sep 2008 02:46:12 +0900 > Von: Azalar --- > An: ruby-talk@ruby-lang.org > Betreff: Re: regular expression match and exclude > > I should mention that image isn't a fixed word in this case I just used > that as an example. > It represents whatever the name of the image is > > So the test data could be.. > > galleries/blah.jpg > galleries/blahthumb.jpg > galleries/landscape.jpg > galleries/landscapethumb.jpg > galleries/foo.jpg > galleries/foothumb.jpg > > > Robert Klemme wrote: > > 2008/9/7 Azalar --- : > >> > >> The array is created when i use the scan method so if i used reject it > >> would become a two pass process which is what i am doing anyway so I > was > >> wondering if regular expressions had built in support for this. > > > > Will be hard. It's easier if you do > > > > %r{galleries/image\d+\.jpg\z} > > > > Kind regards > > > > robert > > -- > Posted via http://www.ruby-forum.com/. Dear Azalar, to achieve searching for some text pattern that is not followed by something else, you need regular expressions with negative lookahead http://www.regular-expressions.info/lookaround.html As far as I know, this is not supported by Ruby's 1.8.x regexps, but there is a special library, Oniguruma, with Ruby bindings available for this. http://oniguruma.rubyforge.org/ Best regards, Axel -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal f�r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer