From: s@... (Stefan Schmiedl) Date: 2002-04-11T02:33:55+09:00 Subject: Re: regex: how to negate sequences? On Wed, 10 Apr 2002 16:32:28 GMT, Tobias Reif wrote: > Hi, > > In > '-f-o>o-bar-->' > , I need to match the string before > --> > , which is > -f-o>o-bar > . How to? > > irb(main):009:0> '-f-o>o-bar-->' =~ /[^-->]+/ ; puts $& > f > nil > > I know why the above doesn't work, but I don't know how to negate a > sequence of characters, instead of negating sets/collections. > Hi Tobias, as Michal pointed out already, you don't negate a sequence, you match the stuff before it. As a side note, you might want to consider using /(.*?)-->/ instead of /(.*)-->/, if the string you're matching against contains more than one -->. You might want to look at http://www.approximity.com/rubybuch2/node22_main.html (German) s. -- Stefan Schmiedl Approximity GmbH http://www.approximity.com Research & Development mailto:stefan@approximity.com Loreleystr. 5, 94315 Straubing, Germany Tel. (0 94 21) 74 01 06, Fax (0 94 21) 74 01 21 shhhh ... I can't hear my code!