You can do this with a simple function so that you don't have to write code every time for each line, or just put string.gsub and a value to replace string.gsub you string.
Function:
local large_name = "BAPass 2013 Hindi 720p DvDRip CROPPED AAC x264 RickyKT" function clean_name(str) local v = string.gsub(str, "(.-)%s([%(%[']?%d%d%d?%d?[%)%]]?)%s*(.*)", "%1") return v end print(clean_name(large_name))
Only string.gsub for value
local large_name = "BAPass 2013 Hindi 720p DvDRip CROPPED AAC x264 RickyKT" local clean_name = string.gsub(large_name, "(.-)%s([%(%[']?%d%d%d?%d?[%)%]]?)%s*(.*)", "%1") print(clean_name)
The replacement template puts the first value (the name of the film) separated by a space and prints it, and also defines the year as the second value to avoid heading errors, so there is no need to place all the values ββthat may exist in the name of the film and avoid many false positives
I add a test function to check different movie titles
local testing = {"Whiplash 2014 [1080p]", "Anon (2018) [WEBRip] [1080p] [YTS.AM]", "Maze Runner The Death Cure 2018 [WEBRip] [1080p] [YTS.AM]", "12 Strong [2018] [WEBRip] [1080p] [YTS.AM]", "Kingsman The Secret Service (2014) [1080p]", "The Equalizer [2014] [1080p]", "Annihilation 2018 [WEBRip] [1080p] [YTS.AM]", "The Shawshank Redemption '94", "Assassin Creed 2016 HC 720p HDRip 850 MB - iExTV", "Captain Marvel (2019) [WEBRip] [1080p] [YTS.AM]",} for k,v in pairs(testing) do local result = string.gsub(v, "(.-)%s([%(%[']?%d%d%d?%d?[%)%]]?)%s*(.*)", "%1") print(result) end
Exit:
Whiplash Anon Maze Runner The Death Cure 12 Strong Kingsman The Secret Service The Equalizer Annihilation The Shawshank Redemption Assassin Creed Captain Marvel