in reply to Re^3: Windows and backslashes and replacements oh my!
in thread Windows and backslashes and replacements oh my!
One $bs is sufficient in my tests:
d:\>perl -E"for $x (qw/C:\berrybrew\test C:\berrybrew /) {$_=$x; $bs=c +hr(92); s/berrybrew(?!\\+test)/berrybrew${bs}test/; say}" C:\berrybrew\test C:\berrybrew\test d:\>
> Obviously Perl needs to escape the backslash inside a regex
not after interpolation of variables like $bs
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Windows and backslashes and replacements oh my! (two escapings in LHS of s///)
by LanX (Saint) on Jun 19, 2021 at 12:09 UTC |
In Section
Seekers of Perl Wisdom