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:name5The result that is needed is:
Landon:m1234@mail.com:name1
Caleb:myr@mail.com:name4
Gavin:phil@ymail.com:name5How 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:excludedAs usual, no problem with regular expressions ;-)). So :
-
Open the Replace dialog (
Ctrl + H) -
Select the
Regular expressionsearch mode -
Tick the
Wrap aroundoption
SEARCH
(?-s)@.+(?=:.+@)REPLACE
Leave EMPTY- Click, once, on the
Replace Allbutton or several times on theReplacebutton
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
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