I have a text file.
I want to keep lines started with <Path>, and delete all the other lines.
How can I do it?
|
I have a text file. I want to keep lines started with How can I do it? | ||||
|
feedback
|
This question came from our site for professional and enthusiast programmers.
|
There is an easy way to achieve this. You need to perform 3 steps.
| |||||
feedback
|
|
Is clumsy, but copy it all to excel, and then use | |||
|
feedback
|
|
Providing that you actually want to match
It worked with Strawberry Perl on Windows, so adjust accordingly if the results are not what you expect. | ||||
|
feedback
|
|
There is no easy way to do what you want with Notepad++. You'll need to either download a program to your computer or script something in VB (I assume you're on Windows). You can do what you want one of two ways with sed. The sed utility is a favorite on *nix and can be found for Windows from the great people at GnuWin (http://gnuwin32.sourceforge.net/packages/sed.htm). You would download this program, and then run your command from the command prompt. Delete all lines not containing : Print all lines containing to a new file: I suggest you use print the lines you want to a new file. The reason for this is that you probably won't get the regex statement for the first time around. The sed utility uses Regular Expression Basic Syntax (view the reference at http://www.regular-expressions.info/reference.html). If is something like a *nix path (/var/www) then you'll need to escape the / character for your regex to work. Example: | ||||
|
feedback
|
|
How about using Regular Expressions to replace ^[^,]+ with nothing. | |||
|
feedback
|
|
Use Search->Replace and enter a regular expression like | |||
|
feedback
|