I don't understand the significance of the (?<!\\\\) assertion in the regex in the OP (copied as-is in tybalt89's reply). It suppresses elision of secret values when the single- or double-quoted key phrase is immediately preceded by a \\ double backslash but not by a single backslash. Is this intended? Output from tybalt89's working code with a few minor output formatting modifications:
c:\@Work\Perl\monks\1nickt>perl tybalt89_pm1206554_1.pl {'password' => 'secret'} -> {'password' => '***'} {"password" => "sec\"ret"} -> {"password" => "***"} {\'password' => 'secret'} -> {\'password' => '***'} {\"password" => "sec\"ret"} -> {\"password" => "***"} {\\'password' => 'secret'} -> {\\'password' => 'secret'} {\\"password" => "sec\"ret"} -> {\\"password" => "sec\"ret"}
Give a man a fish: <%-{-{-{-<
In reply to Re: Matching backslash in regexp negative lookbehind
by AnomalousMonk
in thread Matching backslash in regexp negative lookbehind
by 1nickt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |