简体   繁体   中英

How to copy every line in text file containing substring

I have a text file I've been viewing in visual studio code:

here is one line
problem path: path1
another line
value line more info
value
problem path: path2
incredible data line
problem path: path3

And I want to copy every line which includes with the text problem path: so my output result will look like

problem path: path1
problem path: path2
problem path: path3

Can i ctrl+f search for 'problem path' in my text file, select every line where it occurs, and copy/paste those lines into a new file?

This is the expression you can use https://regex101.com/r/wJVNJR/1

Find: problem path:.+

You have to use a programming language to write the content to a separate file.

  • open find box Ctrl+F
  • type problem path: or some regex
  • press Alt+Enter
  • press Home incase a line contains multiple finds and to get only a cursor and not a selection on the line
  • press Ctrl+C
  • in the other file: Ctrl+V

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM