Skip to main content

VERSION_REGEX

Static VERSION_REGEX 

Source
pub static VERSION_REGEX: Lazy<Regex>
Expand description

Explicit version-marker detector. Ported from QualityParser.cs:43-44.

The C# pattern declares the same <version> named group on FIVE alternation branches:

  1. \d[-._ ]?v(?<version>\d)[-._ ] (e.g. 1v2., 01-v2_)
  2. \[v(?<version>\d)\] (e.g. [v2])
  3. repack(?<version>\d) (e.g. repack2)
  4. rerip(?<version>\d) (e.g. rerip3)
  5. (?:480|576|720|1080|2160)p[._ ]v(?<version>\d) (e.g. 1080p.v2)

.NET allows duplicate names and merges captures; Rust’s regex crate rejects them. We rename branches 2-5 to version2, version3, version4, version5. Callers should walk all five names and pick the first hit:

caps.name("version")
    .or_else(|| caps.name("version2"))
    .or_else(|| caps.name("version3"))
    .or_else(|| caps.name("version4"))
    .or_else(|| caps.name("version5"))

T6’s modifier cascade owns that walk; the helper is intentionally not added in T5 because the cascade has additional decision logic that would be split awkwardly. Case-insensitive (IgnoreCase in C# → (?i) flag here).