in reply to Using Look-ahead and Look-behind
Thank you for your very nice article, I certainly learned some new tricks!
Just one little comment: The code in the last paragraph did not work because by default regular expressions are greedy. (Did this change with the Perl versions in between?) The only right-substring that comes out is the full string:
Output:$_ = "Hello"; print "$1\n" while /(?=(.*))/g;
Making the "(.*)" part non-greedy fixes it (in Perl 5.10):Hello
Output:$_ = "Hello"; print "$1\n" while /(?=(.*)?)/g;
Hello ello llo lo o
In Section
Tutorials