I have a sample list of file names that I'd like to capture just the 'name' and the optional s##e##. Everything else I don't need. I used regex101.com to test the pattern that I would be using in Java later.
Heroes (2006) - s01e01 - Genesis.mp4
[Not-Important] One Piece - s22e48 - 1178 [More_not_important].mkv
Stargate s01e01.mkv
Stargate the Movie.mkv
Star-Trek s01e01.mkv
(Not_Important) Star_Trek_the_Movie (Some-More).mkv
and I have this Java regex patte
(?:^[[(].*?[])])?(.*?)([sS]d+[eE]d+)([^.]*)
which resulted:
Match 1 => Heroes (2006) - s01e01 - Genesis
Group 1 => Heroes (2006) -
Group 2 => s01e01
Group 3 => - Genesis
Match 2 => [Not-Important] One Piece - s22e48 - 1178 [More_not_important]
Group 1 => One Piece -
Group 2 => s22e48
Group 3 => - 1178 [More_not_important]
Match 3 => Stargate s01e01
Group 1 => Stargate
Group 2 => s01e01
Group 3 => empty string
Match 4 => (I would like to capture 'Stargate the Movie' but the pattern did not capture anything )
Match 5 => Star-Trek s01e01
Group 1 => Star-Trek
Group 2 => s01e01
Group 3 => empty string
Match 6 => (I would like to capture 'Star_Trek_the_Movie' but the pattern did not capture anything )
I'd looking to capture 'name' which is group 1 without the '(2006)' in the example and the optional
[sS]d+[eE]d+
and ignore everything inside (and including) the brackets and/or parentheses. So the match 1 group 1 should just return 'Heroes'. I tried adding more but ended no changes or got worse results.
برچسب:
نویسنده: استخدام کار