Regex help. Trying to capture closing parenthesis after duscarding earlier text

Answered

I was going to post this in the regex subreddit but that looks kind of dead-ish.

So I'm trying to capture two parts of a title from youtube (playlist: https://www.youtube.com/playlist?list=PLXhfRoiJBIivtqHn3nbCOW6TQsuF2DbR0, upload: https://www.youtube.com/watch?v=c8SrAz6wWfs). The titles are in the form of text - text - text (text), specifically King Crimson - Announcement - Live June 30th 1974 (The Great Deceiver Pt. 1) and I am trying to end up with Announcement - Live June 30th 1974 (The Great Deceiver) (and similar for all the other items in the playlist).

--parse-metadata "title:\s-\s(?P<title>.*)\sPt" will get me Announcement - Live June 30th 1974 (The Great Deceiver which is good but it's missing the trailing parenthesis. The Regex101 site says that adding (\)) onto the end such as --parse-metadata "title:\s-\s(?P<title>.*)\sPt(\))" works but when I do that such as --parse-metadata "title:\s-\s(?P<title>.*)\sPt(\))" (with or without a .* after Pt) it causes a parse error.

Any solutions are appreciated because I'm tearing my hair out here.

Posted Jun 8, 2026, 12:18 AM UTC

38
Loading comments…