Given a constant prefix and no terminating suffix (i.e., terminates at end of string) (5.10+ needed for \K):
c:\@Work\Perl\monks>perl -wMstrict -le "use 5.010; ;; my @strings = ('/ba/mn/first one', '/ba/mn/second', '/ba/mn/third'); ;; my $prefix = qr{ /ba/mn/ }xms; ;; for my $s (@strings) { printf qq{string '$s' -> parts }; my @parts = $s =~ m{ $prefix \K .* }xmsg; printf qq{'$_' } for @parts; print ''; } " string '/ba/mn/first one' -> parts 'first one' string '/ba/mn/second' -> parts 'second' string '/ba/mn/third' -> parts 'third'
In reply to Re: Pattern Matching
by AnomalousMonk
in thread Pattern Matching
by sunil@perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |