-2

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?

POVR2
  • 87
  • 10
  • Do you want to automate the creation and opening of the new file at the same time? That can be done easily as well as copying the lines you are interested in. – Mark Sep 26 '22 at 22:12

2 Answers2

0

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.

Mark
  • 143,421
  • 24
  • 428
  • 436
  • Can i do this without writing a script? In vscode i can ctrl+f and select an icon to enter regex, doing so will highlight all the rows but i can only copy them individually – POVR2 Sep 26 '22 at 19:52
  • https://stackoverflow.com/questions/46539714/select-all-occurrences-of-selected-word-in-vscode#:~:text=Ctrl%20%2B%20F2%20will%20select%20all,select%20occurrences%20one%20by%20one. here is your answer – Nicholas Hansen-Feruch Sep 26 '22 at 19:53
0
  • 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
rioV8
  • 24,506
  • 3
  • 32
  • 49