From: Simon Strandgaard Date: 2004-05-14T22:36:29+09:00 Subject: Re: Regexp Error? Ara.T.Howardwrote: > On Fri, 14 May 2004, Kristof Bastiaensen wrote: > > On Fri, 14 May 2004 20:18:55 +0900, ts wrote: > > >>>>>> "R" == Robert Klemme writes: > > > R> irb(main):023:0> "123-456".gsub(/.*/, 'X') > > > R> => "XX" > > > > > > * first match : "123-456" > > > * now it's at end > > > * second match with the empty string > > > > > > > I would say the empty string is included with "123-456", > > so it shouldn't give another match: > > > > echo "123-456" | sed 's/.*/X/g' > > X > > > > Kristof > > yes but > > ~ > echo "123-456" | perl -npe 's/.*$/X/g' > XX > > and sed regexps are not the same as perl/ruby right? This is a widespread problem with regexp, when dealing with kleene star, its tricky to detemine when to stop looping. I have putted lot of effort investigating where to stop in my engine, so the output is the most desired. Unfortunatly Ruby's native regexp engines (GNU or Oniguruma) attempts to be perl compatible, and thus sometimes emulating a non-desired behavior. -- Simon Strandgaard