in reply to Re^2: Combining regexes
in thread Combining regexes
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: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Combining regexes
by BrowserUk (Patriarch) on May 21, 2016 at 17:48 UTC | |
by AnomalousMonk (Archbishop) on May 21, 2016 at 17:58 UTC | |
by BrowserUk (Patriarch) on May 21, 2016 at 18:05 UTC | |
by AnomalousMonk (Archbishop) on May 21, 2016 at 18:47 UTC | |
by Anonymous Monk on May 22, 2016 at 00:43 UTC |