Delete text with notepad ++



  • Hi there !, Use notepad ++, I tried to delete text between @ and before “:”, my text is 15678 lines, the text is as follows:

    Landon@mail.com:m1234@mail.com:name1
    Caleb@mac.lt:myr@mail.com:name4
    Gavin@wichi.es:phil@ymail.com:name5

    The result that is needed is:
    Landon:m1234@mail.com:name1
    Caleb:myr@mail.com:name4
    Gavin:phil@ymail.com:name5

    How can I do this?



  • Hello, @lolo-germ and All

    Ok ! Try to be as accurate as possible ! Indeed, you would like to delete any range of characters, between the first arrobas symbol ( @ ) of each line till the nearest colon character : excluded

    As usual, no problem with regular expressions ;-)). So :

    • Open the Replace dialog ( Ctrl + H )

    • Select the Regular expression search mode

    • Tick the Wrap around option

    SEARCH (?-s)@.+(?=:.+@)

    REPLACE Leave EMPTY

    • Click, once, on the Replace All button or several times on the Replace button

    Notes :

    • The (?-s) modifier means that dot ( . ) matches a single standard character, only ( not the EOL of a line-break )

    • Then the part @.+ tries to match an arrobas followed by the longest non-null range of any standard character

    • But, ONLY IF the positive look-ahead structure, (?=......) is TRUE. That is to say if the regex :.+@ is satisfied at the “work position” of the regex engine. In other words, if, right after, a colon character can be found and, further on, a second arrobas character, separated, from the first colon, by a non-null range of chars , .+

    • As the replacement zone is empty, the matched range of characters is just deleted

    Cheers,

    guy038



  • very grateful to you, I’ve tried it and it works


Log in to reply