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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to