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

William Park opengeometry at yahoo.ca
Thu Jan 2 01:59:30 EST 2025


Second method is easier.

    echo"Zero.Dark.Thirty.2012.720p.BrRip.x264.BOKUTOX.YIFY.mp4"| while
    IFS=. read -a x; do
    y=
    skip=0
    fori in"${x[@]}";do
    case$iin
                201[0-9])y+="($i)";;
    [0-9]*p)y+="-$i";skip=1;;
                mp4)y+=".$i";;
                *)if [[skip-eq0]]; theny+="${y:+}$i"; fi ;;
    esac
    done
    echo"y={$y}"
    done

-- 

On 2025-01-01 03:52, William Park via kwlug-disc wrote:
> From the top of my head,
>     - cut the string on ".2012.720p."
>     - change "Zero.Dark.Thirty" to "Zero Dark Thirty "
>     - change ".2012.720p." to "(2012-720p)"
>     - change "BrRip.x264.BOKUTOX.YIFY.mp4" to ".mp4"
>
> Or,
>     - cut the string on "." (period)
>     - loop through the substrings, and search for "2012" and/or "720p"
>     - reassemble parts
> -- 
> William
>
>
> On 2024-12-31 11:22, John Driezen 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.
>
>
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email tokwlug-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/20250102/90d0b188/attachment.htm>


More information about the kwlug-disc mailing list