Skip to content

Instantly share code, notes, and snippets.

@werrpy
Created March 3, 2020 09:55
Show Gist options
  • Save werrpy/7d0b023b7b9c264fd4ed928e2a2329a7 to your computer and use it in GitHub Desktop.
Save werrpy/7d0b023b7b9c264fd4ed928e2a2329a7 to your computer and use it in GitHub Desktop.
let files = [
"Some.Release.2020.9000p.UHD.VR.HDR.EXTREME.5.1.x900-AMAZIN"
]
files.forEach(function(f) {
let newValue = (function (str) {
// 1) letter and letter
str = str.replace(/([\D])\.(?=[\D])/g, "$1 ")
// 2) number and letter
str = str.replace(/([\d])\.(?=[\D])/g, "$1 ")
// 3) . 4 numbers (.year)
str = str.replace(/\.(?=[\d]{4})/g, " ")
// 4) 4 numbers and 3 or 4 numbers followed by i or p (year and resolution, 2020.1080p)
str = str.replace(/(\d{4})\.(?=\d{3,4}[ip])/g, "$1 ")
// 5) S . 2 numbers . 3 or 4 numbers followed by i or p (season and resolution, S01.720p)
str = str.replace(/(S\d{2})\.(?=\d{3,4}[ip])/g, "$1 ")
// 6) 2 letters . number . number (DD.2.0 or AAC.2.0 or DD+.2.0 or DTS-X.7.1)
str = str.replace(/([\D]{2})\.(?=\d\.\d)/g, "$1 ")
return str
})(f)
console.log("Old: " + f)
console.log("New: " + newValue + "\n")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment