picture of notes imported from an amazon kindle in vscode

This is a picture of my notes, when I import them in from the Kindle.
And every time I have to corral them into some sort of structure or write a blog post, I needed to laboriously get rid of all the Kindle metadata with multiple searches (and replaces.)

I mean these lines

Draft No. 4 (John McPhee)
- Your Highlight on page 27 | location 406-407 | Added on Sunday, 15 August 2021 12:43:15

But having learnt Regex about a year ago, I have been using it on and off and have come to appreciate the power it offers.
And I’ve been increasingly trying to solve all of my text search issues using regex, everywhere.1

With a recent book, I managed to use regex to get rid of single lines all at once.
It still took me 3 sets of search and replaces though.
So today, I got lazier and curiouser and wondered if I could do all three lines together.
I was trying combinations of /g and /gs to somehow get the regex engine to span lines, but no dice.
A bit of web surfing led me to this post which told me that, all I needed to do was match newline literals \n
This led, to me tinkering and coming up with this search regex
Which led to …

picture of notes imported from an amazon kindle in vscode with search results

matching everything in one fell swoop!
All hail the power of regex!

P.S. Subscribe to my [mailing list][1]! Forward these posts and letters to your friends and get them to subscribe! P.P.S. Feed my [insatiable reading habit][2].

  1. (emphasis on trying. I’m no regex genius) ↩︎