Skip to content

Commit

Permalink
update regex
Browse files Browse the repository at this point in the history
  • Loading branch information
spektor56 committed Sep 22, 2020
1 parent 74fff73 commit b68c2dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions LBGDBMetadata/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace LBGDBMetadata.Extensions
{
public static class StringExtensions
{

private static readonly Regex SanitizeRegex = new Regex(@"((^the\s+)|([^A-Za-z\s]+\s*the(?![A-Za-z])))|((^an\s+)|([^A-Za-z\s]+\s*an(?![A-Za-z])))|((^a\s+)|([^A-Za-z\s]+\s*a(?![A-Za-z])))|[^A-Za-z0-9]", RegexOptions.IgnoreCase | RegexOptions.Compiled);

public static string Sanitize(this string text)
{
/*
Expand All @@ -15,8 +18,7 @@ public static string Sanitize(this string text)
text = Regex.Replace(text, @"(^|\s+){1}VII($|\s+){1}", "7", RegexOptions.IgnoreCase);
text = Regex.Replace(text, @"(^|\s+){1}VIII($|\s+){1}", "8", RegexOptions.IgnoreCase);
*/

return Regex.Replace(text, @"(((^|\s+){1}|(,\s+){1})the($|\s+){1})|(((^|\s+){1}|(,\s+){1})an($|\s+){1})|(((^|\s+){1}|(,\s+){1})a($|\s+){1})|[^A-Za-z0-9]", "", RegexOptions.IgnoreCase).ToLower();
return SanitizeRegex.Replace(text, "").ToLower();
}

public static string ConvertRomans(this string text)
Expand Down
9 changes: 6 additions & 3 deletions LBGDBMetadata/LbgdbMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using LBGDBMetadata.Extensions;
using LBGDBMetadata.LaunchBox;
using LBGDBMetadata.LaunchBox.Metadata;
using Microsoft.EntityFrameworkCore;
using Playnite.SDK.Metadata;
using Playnite.SDK.Models;
using Playnite.SDK.Plugins;
Expand All @@ -21,7 +19,7 @@ public class LbgdbMetadataProvider : OnDemandMetadataProvider
{
private readonly MetadataRequestOptions _options;
private readonly LbgdbMetadataPlugin _plugin;
private LaunchBox.Metadata.Game _game;
private Game _game;
private Dictionary<string, int> _regionPriority = new Dictionary<string, int>();

public LbgdbMetadataProvider(MetadataRequestOptions options, LbgdbMetadataPlugin plugin)
Expand Down Expand Up @@ -347,6 +345,11 @@ public override List<Link> GetLinks()
return base.GetLinks();
}

public override List<string> GetFeatures()
{
return base.GetFeatures();
}

public override List<MetadataField> AvailableFields
{
get
Expand Down

0 comments on commit b68c2dd

Please sign in to comment.