using System.Text.RegularExpressions; namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings; public abstract class DrinkingWaterHeatingFitting : IProductQueryModifier { protected static readonly Regex _diameter = new(@"([\b\D]|^)?(?16|20|25|32|40|50|63)([\b\D]|$)"); protected static readonly Regex _angle = new(@"([\b\D])(?45|90)([\b\D]|$)"); protected static readonly Regex _thread = new(@"([\b\D])(?1\s+1/4|1\s+1/2|1/2|3/4|2|1)([\b\D]|$)"); protected virtual string _title { get; } = string.Empty; public bool TryQueryModify(string input, out string output) { output = BuildRhSolutionsName(input) ?? string.Empty; return !string.IsNullOrEmpty(output); } protected virtual string? BuildRhSolutionsName(string query) { var match = _diameter.Match(query); if (match.Success) { return $"{_title} {match.Groups["Diameter"]}"; } return null; } }