Using RegEx to create a "Saved Quotes" Shortcut

2019 April 10th

“It takes a ridiculous amount of courage and humility to suck at something for a while.”

— Merlin Mann, Back to Work, Episode 229: Shrimp in the Desert

I love collecting quotes. Collecting them is kinda corny and maybe overly earnest, but some of the most important shifts in my life have come because of a quote I heard on a podcast, and interview, or in a sermon. Something I frequently want to do when I’m listening to a podcast is to record a quote that I’ve heard and save it somehow.

My podcast player of choice is Overcast, made by developer & podcaster Marco Arment. I wanted to find a way to run a Siri Shortcut inside of Overcast, record the quote and author, grab the podcast title and episode, and save to my quotes Day One journal (my preferred journaling app). However, when I tap the share icon in Overcast the only info I get is a link to the episode’s Overcast webpage, which doesn’t leave me many options for getting the podcast data.

Enter: Regular Expressions, or RegEx. From my understanding from my developer friends, RegEx is thought by many to be incredibly powerful, incredibly annoying, and incredibly fiddly.

Shortcut Overview

Most of the shortcut is pretty straightforward:

  1. Ask for Input: Quote body ☑️
  2. Ask for Input: Author ☑️
  3. Some how grab the podcast metadata using RegEx 😬
  4. Put the quote into Day One as a new journal entry ☑️

Side note: I used and it helped so much with the trial and error required to get the right result. I highly recommend it if you’re getting started.

iPad screenshot of the Shortcuts app showing the RegEx

RegEx on the HTML

After we Ask for Input, we Get the Contents of the URL, and convert that into HTML from Rich Text. In Shortcuts, the Match Text function gives you the ability to search the inputed text using regular expressions and it results with the text that it matches. Luckily, Overcast has descriptive meta tags, if they didn’t, it would have been a much more complicated page scrape. There’s a title HTML meta tag in the HEAD that had everything I needed to grab in one line:

To get the episode's name I used:

(?<=<meta name="og:title" content=").\*?(?=&mdash;)

and to get the podcast's name I used:

(?<= &mdash; ).\*?(?=" \\/>)

From there, I created a new Day One Entry, adding a # to the quote to make it an H1 (I mostly did this because I liked how it looked better inside of Day One).

# "Quote"
— Author

Podcast Name
Podcast Episode

I’ve created a more generic version of the Shortcut for others to use. Please download it below. I’ve removed the creation of the Day One entry, since it was setup for my personal use. Shout out to my buddy Kris Kroski who reluctantly taught me the basics of RegEx.

iPad screenshot of the Shortcuts app showing the DayOne entry to be created

The shortcut must be run from the share sheet inside of the Overcast app.

Download the "Podcast Quote from Overcast" Shortcut