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

Re: regex for identifying encrypted text

by cavac (Curate)
on May 16, 2018 at 12:22 UTC ( #1214649=note: print w/replies, xml ) Need Help??


in reply to regex for identifying encrypted text

So the problematic block of lines start with set private ", then some junk that doesn't containt quotes and then it ends with a quote, right?

You seem to be parsing this line-by-line, correct? So, modifying your code to make a very rudimentary state machine, i'd guess something like this would do:

my $isprivatekey = 0; for my $line (@diff) { if($isprivatekey) { if($line =~ /\"/) { # last line of private key $isprivatekey = 0; } next; } if($line =~ /set\ private\-key/) { # uh, get some useless stuff here $isprivatekey = 1; next; } next LINE if $line =~ /set password ENC/; [...] }

This should skip the whole private key block altogether

"For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."

Replies are listed 'Best First'.
Re^2: regex for identifying encrypted text
by hippo (Canon) on May 16, 2018 at 12:44 UTC

    The problem with this approach is that the line with "set private" is the same in both files and therefore will not be featured in the diff. The data between these markers must be removed before the diff is performed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1214649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-12-16 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many stories does it take before you've heard them all?







    Results (71 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!