Community
    • Login

    Remove lines that meet a requirement using notepad ++

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 3 Posters 2.6k Views
    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
      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
        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
          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
            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
              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
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors