[kwlug-disc] Regular Expression to Match Movie Titles and Year and Ignore the rest.

Jason Eckert jason.eckert at gmail.com
Tue Dec 31 14:40:54 EST 2024


You could also use:

^([A-Za-z]+(?:\.[A-Za-z]+)*)\.(\d{4})\.(\d+p)\..*\.(mp4|mkv|avi)$

Explanation:
^: Anchors the regex to the start of the string.
([A-Za-z]+(?:\.[A-Za-z]+)*): This part matches the title. It captures words
separated by dots (e.g., Zero.Dark.Thirty will be captured as Zero Dark
Thirty).
([A-Za-z]+): Matches the first word.
(?:\.[A-Za-z]+)*: Matches any additional words separated by dots.
\.(\d{4}): Matches the year (a 4-digit number).
\.(\d+p): Matches the resolution (e.g., 720p, 1080p).
\..*: Matches any additional characters between the resolution and the file
extension (e.g., BrRip.x264.BOKUTOX.YIFY).
\.(mp4|mkv|avi): Matches the file extension (mp4, mkv, avi, etc.).

On Tue, 31 Dec 2024 at 11:29, John Driezen <jdriezen at sympatico.ca> wrote:

> Can anyone give me a regular expression to turn the following filename
>
>   "Zero.Dark.Thirty.2012.720p.BrRip.x264.BOKUTOX.YIFY.mp4"
>
> into
>
> "Zero Dark Thirty (2012)-720p.mp4"
>
> 201[0-9] matches the year
>
> How do I match the title before the year, and ignore everything after
> the ".720p"?
>
> John Driezen
>
>
>
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
> with the subject "unsubscribe", or email
> kwlug-disc-owner at kwlug.org to contact a human being.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20241231/943a5bbc/attachment.htm>


More information about the kwlug-disc mailing list