Notepad++ Regex to delete a line

830 pts.
Tags:
as/400 data
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

Use the Extended mode, not the RegEx mode. Then this should work for you:

\\\r

Discuss This Question: 8  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • TomLiotta
    Nope. It changed my right-square-brackets to right-angle-braces. Let's try: ^[^/>*/[^/>*$ Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • DoneThat
    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 pointsBadges:
    report
  • DoneThat
    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 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • DoneThat
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following