How to extract text with a certain condition with notepad?



  • 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



  • @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



  • @Scott-Sumner said:

    Bookmark

    thanks you Scott Sumner


Log in to reply