Simple question. How do you Remove any text after and including* the symbol @ on Notepad++?
100@S5
100@S6
100@S7
101@S8
I have thousands of these to remove to leave the numbers before. Thanks in advance.
None.
We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch
can't you replace @?? with [blank]?
yeah but that wont remove all the random text after the @ as well
None.
Regular expressions?
Also try the TextFX search/replace under the Quick menu I believe it is, this one works a little different from the standard search/replace so you may get better results.
None.
I'd go with the "regular expressions" thing as the best suggestion; personally, I'm too lazy to learn them, and believe that (depending on what the exact text you're dealing with is - more rather, how it's formatted), macros would also be quite useful.
None.
I can write you a C program to do it for you if you like. PM if you want me to.
None.
Record a macro:
- Before recording, do a find for @ once such that you can press F3 to find again.
- Begin recording. Don't press any other buttons until finished.
- Enter the following keys: F3, Enter, Down, Left, Ctrl+Shift+Backspace, Backspace
- Stop recording.
- Select 'Run a Macro multiple times...' and for the current macro simply run it until end of file is reached.
Be sure to test it out, first.
None.
Woah you guys, way way over the top. Regular expressions are all you need, and Notepad++ can do it easily. When I posted my reply I was at work where we have Ubuntu so didn't have Notepad++ and wasn't interested in trying to install it or anything (since our ubuntu desktops are set up with better programs anyway).
Using the sample of 4 lines provided, this regular expression works:
Search: (.*)@.*
Replace: \1
Breaking it down: find 0 or more any characters and call this section 1, then find the @ symbol followed by 0 or more any characters. Replace this segment with the contents of section 1. This logic effectively splits the string into 2 parts based on the first @ symbol it finds and throws the second part away.
To use this, click Search menu then Replace (or press ctrl + H). Click on Regular Expression radio button on the bottom left under Search Mode.
Here are some references for the various search/replace tools in Notepad++:
http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Searching_And_Replacinghttp://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Replacing_Newlineshttp://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Regular_ExpressionsNote that Notepad++ actually doesn't support the full set of regular expression operations and the syntax is slightly different from other tools. It also has rather poor handling of new line characters in general - only Extended mode can find search strings that include new lines, but then you can't use the regular expressions in the replace string. Just tried out the TextFX and that seems to handle new lines much better - last time I tried (probably about a year ago) I couldn't get it to find and replace a newline using regular expressions anywhere, so I guess I've got a newer version of Notepad++ now or something.
Post has been edited 2 time(s), last time on Dec 9 2011, 11:17 am by Lanthanide.
None.
SDE, BWAPI owner, hacker.
Search ->
Replace...Then under
Search Mode select
Regular Expression.
Type
Quote from Replace with :
then click
Replace All. Done.
Woah you guys, way way over the top.
But still simple enough not to be a problem.
Depending on how much he does anything with his computer, "learn regular expressions" could easily be
more over-the-top than "use this entirely self-explanatory tool that takes five seconds to setup".
Granted, most people who use Notepad++ use computers enough that they should learn regex, and nowadays most with access to computers at all are also above that threshold, but... uh, did I have a point? Oh well, whatever.
None.
Cecil was going to write a c program to do it. Tux's macro solution takes longer and is more error prone. In this case the regular expression really isn't anything complicated.
@Heinermann - duh, don't know why I didn't think of that
None.
Tux's macro solution takes longer and is more error prone.
Not more than regex if you know what you're doing, and arguably just as valuable to learn.
None.
So you think you can record that macro and then run it enough times to replace all instances faster than Heinermann can enter his regex and click "replace all"?
None.
Comparably close. It's not the ideal tool problems like these, but I'm used to using it more than regex, so it's fine for me. Though if I do need serious use of macros I often resort to a separate, dedicated application.
And yes, I've used regex with macros in the past.
None.
Cecil was going to write a c program to do it.
Well, writing simple programs is just fun.
Tux's macro solution takes longer and is more error prone.
Well, again, my point was that a. "takes longer" is pretty insignificant in this case, and b. yes, "takes longer" if you
already know regex, which IAGG presumably doesn't - if you include "time it takes to wait for someone to post the regex on a forum", or "time it takes to read a 5+ page tutorial on an unfamiliar language", then no, the macro solution may be many times faster.
None.
Thanks. Worked perfectly!
None.