Thanks everyone, The solution of John W. Krahn works perfectly :) Incredible
On Tue, Apr 27, 2010 at 1:41 PM, John W. Krahn <[email protected]> wrote: > HolyNoob wrote: > >> Hi, >> > > Hello, > > > I'm trying to make a regexp to match the last appearance of a word (lets >> say >> 'abc') until the first appearance of another word (for ex: 'xyz'), and I >> still cannot do it. >> >> For example: with a string like this "abc abc abc toto toto xyz xyz xyz" , >> which regexp I have to use to get "abc toto toto xyz". >> I can extract this "abc abc abc toto toto xyz" with m/abc(.*?)xyz/ >> > > No you can't. You can extract " abc abc toto toto " with m/abc(.*?)xyz/. > If you want to extract "abc abc abc toto toto xyz" then you have to use > /(abc.*?xyz)/. > > To extract "abc toto toto xyz" try /.*(abc.*?xyz)/. > > > > John > -- > The programmer is fighting against the two most > destructive forces in the universe: entropy and > human stupidity. -- Damian Conway > > > -- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > http://learn.perl.org/ > > >
