toulax@gmail.com
6/29/2007 4:26:00 AM
On Jun 29, 1:11 am, "yer...@gmail.com" <yer...@gmail.com> wrote:
> On Jun 28, 10:27 pm, "tou...@gmail.com" <tou...@gmail.com> wrote:
>
>
>
> > Like I said it has to be a regular expression, nothing else, any
> > ideas?
>
> > On Jun 28, 11:24 pm, "Stephen Ball" <sdb...@gmail.com> wrote:
>
> > > On 6/28/07, dbl...@wobblini.net <dbl...@wobblini.net> wrote:
>
> > > > Hi --
>
> > > > On Fri, 29 Jun 2007, Jesse Hk wrote:
>
> > > > > Am I missing something here? Why not just test for equality?
>
> > > > > irb(main):001:0> "foo" == "foo"
> > > > > => true
> > > > > irb(main):002:0> "foo" == "bar"
> > > > > => false
>
> > > > That doesn't cover the case where the string includes the substring
> > > > "bar" but also includes other characters.
>
> > > > David
>
> > > In that case it still works, so we have:
>
> > > "foo" => "foo"
>
> > > irb(main):001:0> "foo" == "foo"
> > > => true
>
> > > "bar " => nil
>
> > > irb(main):002:0> "foo" == "bar"
> > > => false
>
> > > "foobar" => nil
>
> > > irb(main):003:0> "foo" == "foobar"
> > > => false
>
> > > -- Stephen
>
> As Axel said, you need to use a regex with negative lookahead. This
> should work:
> /b(?!ar)/
> as long as whichever language/system you're using supports it. Maybe
> there's a better group or forum for your question if you're not using
> Ruby.
>
> I would have thought this would work:
> /.*(?!bar)/
> but it doesn't in Ruby. I would take that to mean 0 or more of any
> character not followed by bar, but I guess that's not the case. I
> (obviously) don't understand negative lookahead all that well. Can
> anybody explain?
>
> Jeremy
Thanks Jeremy, as you said this doesn't seem to work, but thanks for
pointing me to the right track. Also if anyone can suggest a group
more specific to regexp I'm all ears.