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
/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
This led, to me tinkering and coming up with this search regex
Which led to …
matching everything in one fell swoop!
All hail the power of regex!
(emphasis on trying. I’m no regex genius) ↩