Further to some of BrowserUk's comments ++above:
(Note that the final \ (backslash) in the $startdir assignment has to be escaped because it's just before the closing single-quote delimiter.)c:\@Work\Perl\monks>perl -wMstrict -le "my $curdir = 'Y:\Music\Schubert\Lieder\Terfel'; my $startdir = 'Y:\mUsIc\\'; ;; my $plsname = $curdir; $plsname =~ s/^\Q$startdir\E//i; $plsname =~ s/\\/_/g; $plsname .= '.pls'; print qq{'$plsname'}; " 'Schubert_Lieder_Terfel.pls'
(The second example without explicit capture groups.) (Update: Changed code above to add $regex example.)c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'bar foooo bozzle'; ;; my ($capture) = $s =~ m{ (fo+) }xms; print qq{'$capture'}; ;; my ($found_it) = $s =~ m{ (?<= \s) b .* e }xmsg; print qq{'$found_it'}; ;; my $regex = qr{ \A (b \w+) }xms; my ($it_was_there) = $s =~ $regex; print qq{'$it_was_there'}; " 'foooo' 'bozzle' 'bar'
Give a man a fish: <%-{-{-{-<
In reply to Re^3: Combining regexes
by AnomalousMonk
in thread Combining regexes
by davies
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |