Community
    • Login

    Remove lines that meet a requirement using notepad ++

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 3 Posters 3.2k Views 2 Watching
    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.
    • ani rodetA Offline
      ani rodet
      last edited by

      friends it is possible to eliminate those lines that are not complete with your correspondent email, I have the lines

      dozyyqprodus@mybuy.com:dory34
      dozen12@yahoo.com:crhis
      46trgfbf7:dank420
      dp.b2c33:@phill
      terry.hj:6@YD9
      146000@gmail.com:bell2
      2435678eb:~lH@m]
      fjui34:t@,

      the result would be:

      dozyyqprodus@mybuy.com:dory34
      dozen12@yahoo.com:crhis
      146000@gmail.com:bell2

      my text is very big
      thanks you

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS Offline
        Scott Sumner @ani rodet
        last edited by

        @ani-rodet

        What have you tried? Have you used one of the regular expression helper sites to try to build a correct regular expression to match your data?

        1 Reply Last reply Reply Quote 1
        • ani rodetA Offline
          ani rodet
          last edited by

          @Scott-Sumner said:

          What have you tried? Have you used one of the regular expression helper sites to try to build a correct regular expression to match your data?

          thanks, friend I need to delete those that do not have full email, I tried with regular expression but it did not work,

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

            Hello, @ani-rodet, scott-sumner and All,

            Ah, OK, I won’t abandon you, with your big text ;-))

            So, open the Replace dialog ( Ctrl + H )

            SEARCH (?-si)^.+@[a-z]+\.(com|org|net|int|edu|gov|mil)(:\w+)?\R|^.+\R

            REPLACE ?1$0

            • Select the Regular expression search mode

            • Tick the Wrap around option

            • Click on the Replace All button

            Et voilà !

            Notes :

            • I took the main top-level-domains from this link :

            https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains

            • For instance, here are below, the different parts of the regex, with, accordingly, the first line dozyyqprodus@mybuy.com:dory34
            (?-si)^     .+       @  [a-z]+  \.  (com|org|net|int|edu|gov|mil)  (:  \w+  )?    \R     |         ^.+            \R
            
                  >dozyyqprodus  @  mybuy    .             com                  : dory34     CRLF    or  ALL line contents   CRLF
            
            • Just try to guess how this regex works and, please, read some regex documentation ;-) Indeed, that regex is simply made up of basic consecutive structures and it’s not very difficult to build !

            • Regarding the Replacement part,

              • If group 1 exists, (com|org|net|int|edu|gov|mil), all the matched string is re-written

              • If not, the entire line, with its line-break, is deleted

            Best Regards,

            guy038

            1 Reply Last reply Reply Quote 1
            • ani rodetA Offline
              ani rodet
              last edited by

              great friend, thank you very much for your help, I’m learning every day,
              If you work, thank you, I do not know how to thank you

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors