in reply to match last element instead of first??

Hi again, I thank you all for your comments. By experience from other forums I somehow expected nothing more than a "RTFM, dork!". I'm very happy that didn't happen here. :-)

Every time I have to try something with perl I have to read the docs, most time the perlre. I read that back and forth, from left to right, but didn't find the answer to my problem.

And yes, m/(.*?)fish(.*)/ was exactly what I was looking for. I just overlooked two things:

- the possibility to tie the "?" to something that's a match pattern itself
- the idea of "greediness" in matches.
Never, not in my darkest dreams, would I have come up with a solution like that. In my opinion a pattern has to find the leftmost match, period. But who am I to judge this - Perl is like that, go with it.

And, as the perldocs say somewhere at the beginning: There's always more than one way to reach your goal. So I will look into the split function also, perhaps that's an alternative to my problem.

So, to come to and end, I hope I don't have to ask a lot of questions here - but of course I will if there's another problem. ;-)

Thanks again and have a nice day all,
Faltblatt

  • Comment on Re: match last element instead of first??