Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Matching backslash in regexp negative lookbehind

by AnomalousMonk (Chancellor)
on Jan 02, 2018 at 22:53 UTC ( #1206567=note: print w/replies, xml ) Need Help??


in reply to Matching backslash in regexp negative lookbehind

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:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Matching backslash in regexp negative lookbehind
by 1nickt (Monsignor) on Jan 03, 2018 at 00:16 UTC

    The double backslash thing was an artifact, not needed in the code that tybalt89 gave. Thank you for your solutions also.


    The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1206567]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2018-07-16 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (352 votes). Check out past polls.

    Notices?