I have a text file with information about a recording, including track numbers and names, and I want to delete all the other text except the track number and track names. For example the text file looks like this:
text text text text
text text text text text text text text
text text text text text text text text text text text text
text text text text
text text text text text text text text
text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text
text text text text
d1t01 - trackname
d1t02 - trackname
d1t03 - trackname
d1t04 - trackname
d1t05 - trackname
d1t06 - trackname
d1t07 - trackname
d1t08 - trackname
d1t09 - trackname
d1t10 - trackname
d1t11 - trackname
text text text text
text text text text text text text text
text text text text text text text text text text text text
text text text text
text text text text text text text text
text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text
text text text text
I want to be left with just this:
d1t01 - trackname
d1t02 - trackname
d1t03 - trackname
d1t04 - trackname
d1t05 - trackname
d1t06 - trackname
d1t07 - trackname
d1t08 - trackname
d1t09 - trackname
d1t10 - trackname
d1t11 - trackname
I figured out how to match the beginning of the line with this regex:
d[0-9]+t[0-9]+[0-9]+ -
But I can't figure out how to delete the rest of the "text" and only leave those lines. I also need it to delete the "returns" and not be left with any blank lines in the text file.
Thank you!
hwnd's answer is close, but it won't remove all the new lines. You said you don't want any blank lines in the file at all, so this would be a more complete solution:
In this case, your initial body of text would be replaced by
EDIT: You should be able to use the following here.
Regular Expression:
Step 1 - Match lines. Find dialog > Mark tab, you can bookmark lines that match.
Step 2 - Remove lines bookmarked OR Remove lines not bookmarked. Search > Bookmark > Remove Unmarked Lines or Remove Bookmarked lines