• Login
Community
  • Login

How to extract text with a certain condition with notepad?

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 5.5k 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.
  • A
    ani rodet
    last edited by Sep 6, 2018, 3:58 PM

    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

    S 1 Reply Last reply Sep 6, 2018, 5:25 PM Reply Quote 0
    • S
      Scott Sumner @ani rodet
      last edited by Scott Sumner Sep 6, 2018, 5:26 PM Sep 6, 2018, 5:25 PM

      @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
      • A
        ani rodet
        last edited by Sep 6, 2018, 8:22 PM

        @Scott-Sumner said:

        Bookmark

        thanks you Scott Sumner

        1 Reply Last reply Reply Quote 1
        1 out of 3
        • First post
          1/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors