830 pts.
 Notepad++ Regex to delete a line
Well I've put in a lot of time, effort, energy & it's a complete bust. Using Notepad++ Regex, does anyone know how to "delete any line containing 1 and only 1 slash (/)"? Here is a sample file... 1. C;Directory1 2. C;Directory1Filename 3. C;Directory2 4. C;Directory2Filename 5. any text In the above sample, lines 1 and 3 would be deleted. Even a 2 pass method would be fine...I.E. a blank line is left and then going back with "Extended Mode" to get rid of those. If you know of another free Windows editor that can do it (using any method) - THAT would be fine! I DID start to develop a 3 pass method but I'd rather find someone that might actually know how to do it!

Software/Hardware used:
Windows Notepad++ Regex
ASKED: December 21, 2011  8:18 PM
UPDATED: March 17, 2012  6:00 AM

Answer Wiki:
Use the Extended mode, not the RegEx mode. Then this should work for you: \r
Last Wiki Answer Submitted:  January 12, 2012  6:49 pm  by  Holyhandgrenade   15 pts.
All Answer Wiki Contributors:  Holyhandgrenade   15 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Finding the lines is easy enough. I’m not sure how easy it’ll be to put the expression into this editor tough. I’ll try:

^[^/>*/[^/>*$

Let’s see how that looks.

Tom

 107,915 pts.

 

Nope. It changed my right-square-brackets to right-angle-braces. Let’s try:

^[^/>*/[^/>*$

Tom

 107,915 pts.

 

Hmmm… it doesn’t seem to like the closing square brackets after the slashes. Sorry, I don’t know enough about how this editor (or the page rendering) chooses what characters to display.

caret
open square bracket
caret
right slash
close square bracket
asterisk
right slash
open square bracket
caret
right slash
close square bracket
dollar sign

You can figure it out from all of that, I hope.

Tom

 107,915 pts.

 

Wouldn’t you know… in the IT Discussions list, the characters all come out okay. They just get translated in the comments in this thread (for me, at least).

Tom

 107,915 pts.

 

Tom:
I didn’t know you responded. I updated my question and there were your responses!
I’ll look at what you sent this evening…thanks so much,
Gary

 830 pts.

 

First & foremost: your solution WORKS! THANK YOU…I can feel my hair growing back.
If anybody needs this…copy Tom’s solution and change the Right Angle Brackets to Right Square Brackets. The “spelled out” solution is missing the trailing asterisk.
Additional note: I was so frustrated I asked the wrong question. I wanted to find a single BACKslash (working on Windows directory lines).
Just change each Right Slash in Tom’s solution to 2 (two) Left Slashes.
Really appreciated Tom. If I figure out how to include getting rid of the blank lines in one pass – I’ll post back. But this will do very nicely!
Gary

 830 pts.

 

The “spelled out” solution is missing the trailing asterisk.

You’re right. I was getting frustrated trying to get the blasted thing to post correctly. Anyway, glad I got you far enough along to look for a next step. If it someday turns out that I have some spare time, I’ll see if I can get it all in a one-pass solution.

Tom

 107,915 pts.

 

Would be cool if you can figure out how to delete the line. I am still going to try myself. But before you waste any time, here is a heads up. During my research, I found that it is “inherently not possible” to delete the entire line because Notepad++ is built on Scintilla and apparently that piece of software cannot be forced to recognize the CR/LF as part of the line as other Regex engines do.
At least that’s what I think I determined!
Thanks again though – been using it ever since.
Gary

 830 pts.