Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Delete md5 using notepad

    Help wanted · · · – – – · · ·
    4
    10
    1938
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • rovitie
      rovitie last edited by

      Hi

      I have a long document. Using notepad++ or regex, I want to delete all lines containing md5

      bcf5ce4c7e7718060fe3c921d96fefcc:37:ms
      192.168.0.1:37:ms:N/A
      102ddaf691e1615d5dacd4c86299bfa4:Dead:N/S
      perl:pe:out
      192.168.0.55:Dead:N/S
      sed@@:PATH:file
      8371aba8782aead078fa35475c076f68:67:ms

      How can this be done?
      someone who can help me, please?

      Scott Sumner 1 Reply Last reply Reply Quote 0
      • Scott Sumner
        Scott Sumner @rovitie last edited by Scott Sumner

        @rovitie

        Try this:

        Invoke Replace dialog (default key: ctrl+h)

        Find what zone: ^[a-f0-9]{32}(?-s):.*\R
        Replace with zone: make sure this is empty
        Search mode selection: Regular expression
        Action: Press Replace All button

        Here’s how it works:

        ^[a-f0-9]{32}(?-s):.*\R

        • [Assert position at the beginning of a line (at beginning of the string or after a line break character) (carriage return and line feed, form feed)][1 ] ^
        • [Match a single character present in the list below][2 ] [a-f0-9]{32}
          • [Exactly 32 times][3 ] {32}
          • [A character in the range between “a” and “f” (case sensitive)][2 ] a-f
          • [A character in the range between “0” and “9”][2 ] 0-9
        • [Use these options for the remainder of the regular expression][4 ] (?-s)
          • [(hyphen inverts the meaning of the letters that follow)][4 ] -
          • [Dot doesn’t match line breaks][4 ] s
        • [Match the colon character][5 ] :
        • [Match any single character that is NOT a line break character (line feed, carriage return, form feed)][6 ] .*
          • [Between zero and unlimited times, as many times as possible, giving back as needed (greedy)][7 ] *
        • [Match a line break (carriage return and line feed pair, sole line feed, sole carriage return, vertical tab, form feed)][8 ] \R

        Created with RegexBuddy

        [1 ]: https://www.regular-expressions.info/anchors.html
        [2 ]: https://www.regular-expressions.info/charclass.html
        [3 ]: https://www.regular-expressions.info/repeat.html#limit
        [4 ]: https://www.regular-expressions.info/modifiers.html
        [5 ]: https://www.regular-expressions.info/characters.html
        [6 ]: https://www.regular-expressions.info/dot.html
        [7 ]: https://www.regular-expressions.info/repeat.html
        [8 ]: https://www.regular-expressions.info/nonprint.html

        RegexBuddy settings to emulate N++ regex engine: Application=boost::regex 1.54-1.57 / flavor=Default flavor / replacement flavor=All flavor / ^$ match at line breaks / Numbered capture / Allow zero-length matches

        rovitie cipher-1024 2 Replies Last reply Reply Quote 2
        • rovitie
          rovitie @Scott Sumner last edited by rovitie

          @rovitie said:

          regex

          thanks you very much, sorry friend, but in some lines:
          ftp: a10a057d9aaea35231ca57d8959cc182
          test: 53c80014d7714fd6050257050fe4bb7e
          ftp: 887a100f39384fdb3d950ba1b55acba2: router
          12.0.84.130:197cd7b2019b0d7b867012bca81e1b81:ms
          the regex does not work
          I hope you help me, thanks you

          Scott Sumner 1 Reply Last reply Reply Quote 0
          • cipher-1024
            cipher-1024 @Scott Sumner last edited by

            <@cipher-1024 cooks popcorn and prepares for @Scott-Sumner to respond to the “new” information.>

            @rovitie, read up on regular expressions when you have time they’re a great tool to have. Also when you post examples, try and post different kinds. Posting some examples of what you tried and how it failed is good too. It shows you’re putting in some effort.

            Personally I would try
            ^.*?[a-f0-9]{32}.*?$\R
            That’s a bit like using a great big hammer (I do love the .* metacharacter combo!), where Scott’s was more like a scalpel, but this may work for you.

            Good Luck!

            1 Reply Last reply Reply Quote 3
            • Scott Sumner
              Scott Sumner @rovitie last edited by

              @rovitie

              The moral of the (sad) story is that if you don’t post representative data when you ask for help…or data that shows a pattern but (a) not the right pattern or (b) a misleading pattern…don’t be surprised if the help you receive does not solve your problem. @cipher-1024 has the best answer for you, paraphrasing: “read up on regex and solve your own problem”.

              1 Reply Last reply Reply Quote 1
              • guy038
                guy038 last edited by guy038

                Hi, @rovitie, @scott-sumner, @cipher-1024 and All,

                Two other solutions :

                • Search > Replace... option

                • SEARCH (?-s)^.*[[:xdigit:]]{32}.*\R

                • REPLACE Leave EMPTY

                OR

                • Search > Mark... option

                • Tick the Bookmark line option

                • SEARCH [[:xdigit:]]{32}

                • Search > Bookmark > Remove Bookmark Lines

                Cheers,

                guy038

                Scott Sumner 1 Reply Last reply Reply Quote 1
                • Scott Sumner
                  Scott Sumner @guy038 last edited by

                  @guy038

                  So sad that nothing was said about getting the problem statement right in the first place… :(

                  I guess I don’t understand the utility of [:xdigit:] here when (a) it is tough to remember, and (b) [a-f0-9] is shorter. Is “xdigit” supposed to be faster for the regex engine to process? Okay, so I’m ignoring case here, but the OP’s examples were all in lowercase–but maybe we can’t trust the OP… :-)

                  1 Reply Last reply Reply Quote 0
                  • guy038
                    guy038 last edited by guy038

                    Hi @scott-sumner, and All,

                    I was a bit lazy to develop any idea, in that topic, as, since beginning of day, I was doing tests relative to the problem of the Word wrap feature, with very large files, discussed here :

                    https://notepad-plus-plus.org/community/topic/16468/notepad-7-5-9-release/54


                    Now, Scott, regarding our problem, I did some tests ( again! )

                    I created a .txt file, containing 100,000 MD5 strings and here are the results :

                    • SEARCH (?i-s)^.*[0-9A-Z]{32}.*\R REPLACE Leave Empty => 100,000 lines deleted in 45 seconds

                    • SEARCH (?-s)^.*[[:xdigit:]]{32}.*\R REPLACE Leave Empty => 100,000 lines deleted in 39 seconds

                    • BOOKMARK [[:xdigit:]]{32} + Remove Bookmarked Lines => 100,000 lines deleted in 32 seconds ( 7s + 25s )

                    Interesting, isn’t it ?

                    This means that :

                    • With a very large files and/or with numerous zones to delete, the combination of the Marking String and the Delete Bookmarked features is the best choice ;-))

                    • The [[:xdigit:]] regex syntax seems a bit faster than the (?i)[0-9A-Z] syntax

                    Best Regards,

                    guy038

                    1 Reply Last reply Reply Quote 2
                    • rovitie
                      rovitie last edited by

                      A thousand apologies, I am not an expert in programming, a simple assistant of a company, excuse me Mr. Scott Sumner and cipher-1024, thanks for the help shown.
                      guy038, the regex helped me a lot [[: xdigit:]] {32}, thank you very much

                      Scott Sumner 1 Reply Last reply Reply Quote 3
                      • Scott Sumner
                        Scott Sumner @rovitie last edited by Scott Sumner

                        @rovitie

                        Certainly no apology of any kind needed. It is tough to know what you don’t know. Good that it is working for you. I guess I was a bit harsh so I certainly apologize for that. Of course, I’m probably known for being somewhat harsh. ;-)

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright © 2014 NodeBB Forums | Contributors