From ac96fca6dc0f86df194d398f9727e8fdcff9e45d Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 27 Jun 2023 23:08:29 +0200 Subject: [PATCH] Chapter illegalstring regex --- Tranga/Chapter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tranga/Chapter.cs b/Tranga/Chapter.cs index c36ad3a..006eacc 100644 --- a/Tranga/Chapter.cs +++ b/Tranga/Chapter.cs @@ -15,7 +15,8 @@ public struct Chapter public string url { get; } public string fileName { get; } - private static readonly Regex LegalCharacters = new Regex(@"([A-z]*[0-9]* *\.*-*,*\]*\[*'*\'*\)*\(*~*!*)*"); + private static readonly Regex LegalCharacters = new (@"([A-z]*[0-9]* *\.*-*,*\]*\[*'*\'*\)*\(*~*!*)*"); + private static readonly Regex IllegalStrings = new(@"Vol(ume)?.?", RegexOptions.IgnoreCase); public Chapter(string? name, string? volumeNumber, string? chapterNumber, string url) { this.name = name; @@ -27,7 +28,7 @@ public struct Chapter string volStr = this.volumeNumber is not null ? $"Vol.{this.volumeNumber} " : ""; string chNumberStr = this.chapterNumber is not null ? $"Ch.{chapterNumber} " : ""; string chNameStr = chapterName.Length > 0 ? $"- {chapterName}" : ""; - chNameStr = chNameStr.Replace("Volume", "").Replace("volume", ""); + chNameStr = IllegalStrings.Replace(chNameStr, ""); this.fileName = $"{volStr}{chNumberStr}{chNameStr}"; } } \ No newline at end of file