in reply to Multiline replace regexp.
$q =~ s/^.*$a//sm;
The "m" is for multiline, which is a handy mnemonic.
Update: Although, as discussed in this thread the "m" is not actually required if we understand what nikolay wants correctly. We can golf the whole thing down to:
$q =~ s/.*$a//s;
as here:
#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 1; my $q = 'qqqweqwe asdasdasd zxczxczxc tyutyutyi '; my $a = 'zxczxczxc'; my $want = "\ntyutyutyi\n"; $q =~ s/.*$a//s; is ($q, $want, "With /s only and no anchor - matched");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Multiline replace regexp.
by LanX (Saint) on May 21, 2018 at 13:10 UTC | |
by hippo (Archbishop) on May 21, 2018 at 13:27 UTC | |
by LanX (Saint) on May 21, 2018 at 13:34 UTC |