Community
    • Login

    How to extract text with a certain condition with notepad?

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 5.9k 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

      Hello, I tried to extract and paste in another file a text that has the characters @ @ but I have not succeeded

      tengo el texto

      y@17text@mail.com:telephone1
      y17text@mail.com:telephone12
      y19@text@mail.com:telephone15
      @y31text@mail.com:telephone1345
      y1wtext@mail.com:telephone1789
      @y15text@mail.com:telephone14567
      y18text@mail.com:telephone12345

      I need to extract those that have two or more @ paste them into another file

      y@17text@mail.com:telephone1
      y19@text@mail.com:telephone15
      @y31text@mail.com:telephone1345
      @y15text@mail.com:telephone14567

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

        @ani-rodet

        Try this:

        Invoke Mark dialog (Search (menu) -> Mark…)
        Find what zone: (?-s)^.*?@.*?@.+
        Mark line checkbox: ticked
        Wrap around checkbox: ticked
        In selection checkbox: unticked
        Search mode selection: Regular expression
        Action: Press Find All button
        Next action: Search (menu) -> Bookmark -> Copy Bookmarked Lines
        Next action: Paste wherever suits you

        Here’s how the regular expression part of it works:

        (?-s)^.*?@.*?@.+

        • [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 any single character that is NOT a line break character (line feed, carriage return, form feed)][2 ] .*?
          • [Between zero and unlimited times, as few times as possible, expanding as needed (lazy)][3 ] *?
        • [Match the character “@” literally][4 ] @
        • [Match any single character that is NOT a line break character (line feed, carriage return, form feed)][2 ] .*?
          • [Between zero and unlimited times, as few times as possible, expanding as needed (lazy)][3 ] *?
        • [Match the character “@” literally][4 ] @
        • [Match any single character that is NOT a line break character (line feed, carriage return, form feed)][2 ] .+
          • [Between one and unlimited times, as many times as possible, giving back as needed (greedy)][5 ] +

        Created with RegexBuddy

        [1 ]: http://www.regular-expressions.info/anchors.html
        [2 ]: http://www.regular-expressions.info/dot.html
        [3 ]: http://www.regular-expressions.info/repeat.html#lazy
        [4 ]: http://www.regular-expressions.info/characters.html
        [5 ]: http://www.regular-expressions.info/repeat.html

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

          @Scott-Sumner said:

          Bookmark

          thanks you Scott Sumner

          1 Reply Last reply Reply Quote 1

          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