Deleting text after a certain character in notepad++

No, not secret CIA crap.. but just about as tough to crack for most of us. He's got it all, css, html, xhtml, php.. you name it!

Moderator: Zorro

Deleting text after a certain character in notepad++

Postby BlackCat » May 22nd, 2013, 7:25 pm

Hello. Let's say I have the following lines in n++:

Monday$29190
Tuesday$2495920
Wednesday$20569
Thursday$29459002

I want to text to be manipulated so it reads:

Monday
Tuesday
Wednesday
Thursday

I have gone to Find & Replace and entered this:
Find what: $.*
Replace with: (nothing)

The above entry only works for the first line. Every other line is deleted, reading:

Monday

Highlighting all of the text before accessing the find and replace feature yields no favorable result. I must be missing something. Can someone help me, please? I have over 5,400 lines that need this treatment and I don't want to do it all by hand, lol.
User avatar
BlackCat
 
Posts: 1674
Joined: February 12th, 2011, 12:05 pm

Re: Deleting text after a certain character in notepad++

Postby BlackCat » May 23rd, 2013, 3:41 pm

Never mind, I got it. I just had to uncheck the "matches newline" box. Thanks for reading. ;)
User avatar
BlackCat
 
Posts: 1674
Joined: February 12th, 2011, 12:05 pm

Re: Deleting text after a certain character in notepad++

Postby Bullet Magnet » May 23rd, 2013, 4:32 pm

I coded this app in C#. See if it works for you.

In your case, enter "$" (without quotes) as the string splitter, then open the file and save it once processing is complete.
Attachments
SplitString.zip
Application
(4.25 KiB) Downloaded 1323 times
User avatar
Bullet Magnet
Squad Member
 
Posts: 1472
Joined: February 6th, 2011, 5:53 pm

Re: Deleting text after a certain character in notepad++

Postby BlackCat » May 23rd, 2013, 7:46 pm

Worked! That's so cool!!! Thanks!
User avatar
BlackCat
 
Posts: 1674
Joined: February 12th, 2011, 12:05 pm

Re: Deleting text after a certain character in notepad++

Postby Bullet Magnet » May 24th, 2013, 1:03 am

Wow. You literally posted that you had fixed it after I had decided to code the app, so I didn't even see that reply until just now. Oh well... Now you have two methods.
User avatar
Bullet Magnet
Squad Member
 
Posts: 1472
Joined: February 6th, 2011, 5:53 pm

Re: Deleting text after a certain character in notepad++

Postby BlackCat » May 24th, 2013, 8:25 am

How long did it take you to code the app? I sorries, I should have edited the original post instead of replying to myself lol. Is C# coding hard?
User avatar
BlackCat
 
Posts: 1674
Joined: February 12th, 2011, 12:05 pm

Re: Deleting text after a certain character in notepad++

Postby BlackCat » August 29th, 2013, 3:16 pm

For those finding this topic through search engines and are disappointed to find not a clear enough answer for the above mentioned problem, here's what to do.

Go to the replace box. Make sure the regular expression box is enabled.

Find what: [$].*
Replace with: (leave blank)

This will delete everything after $. The brackets separate the symbol from being confused as regex code. If it is "cat" instead of the dollar sign, no brackets are necessary.
User avatar
BlackCat
 
Posts: 1674
Joined: February 12th, 2011, 12:05 pm


Return to El Zorro's casa de la Codes

Who is online

Users browsing this forum: No registered users and 23 guests

cron