Skip to content

Commit

Permalink
Cleaned up the smart list name when duplicating a list from the searc…
Browse files Browse the repository at this point in the history
…h browser.
  • Loading branch information
maforget committed Aug 20, 2024
1 parent ba7cd41 commit 4056911
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ComicRack/Views/ComicBrowserControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
Expand Down Expand Up @@ -2072,8 +2073,8 @@ private void DuplicateList(ComicListItemFolder clif = null)
}
foreach (ComicBookValueMatcher item in comicSmartListItem.Matchers.Recurse<ComicBookValueMatcher>((object cbm) => (!(cbm is ComicBookGroupMatcher)) ? null : ((ComicBookGroupMatcher)cbm).Matchers))
{
string text = item.MatchValue.Trim();
if (!string.IsNullOrEmpty(text))
string text = CleanListName(item.MatchValue.Trim());
if (!string.IsNullOrEmpty(text))
{
if (!string.IsNullOrEmpty(name))
{
Expand All @@ -2100,6 +2101,18 @@ where NumberedString.StripNumber(cli.Name) == name
}
}

private string CleanListName(string matchValue)
{
//Ex: (?<=^)\s*Series\ Name\s*(?=$)
string output = string.Empty;

// Look for the pattern and remove known regex syntax manually
if (matchValue.StartsWith("(?<=^)\\s*") && matchValue.EndsWith("\\s*(?=$)"))
output = Regex.Unescape(matchValue[9..^8]);

return output;
}

private void SetListBackgroundImage(ComicBook cb)
{
SetListBackgroundImage(cb?.Id.ToString());
Expand Down

0 comments on commit 4056911

Please sign in to comment.