0
0
RhSolutions-Api/RhSolutions.Parsers/DrinkingWaterHeatingFittings/DrinkingWaterHeatingFitting.cs
Serghei Cebotari 29d7096786
All checks were successful
Test and release / test (push) Successful in 2m50s
Test and release / release-image (push) Successful in 5m9s
Improve fittings regex
2024-04-26 21:55:54 +03:00

31 lines
793 B
C#

using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
public abstract class DrinkingWaterHeatingFitting : IProductParser
{
protected static readonly Regex _diameter =
new(@"(?<!^)[\b\D]?(?<Diameter>16|20|25|32|40|50|63)[\b\D]?");
protected static readonly Regex _angle =
new(@"(?<!^)([\b\D])(?<Angle>45|90)([\b\D]|$)");
protected static readonly Regex _thread =
new(@"(?<!^)([\b\D])(?<Thread>1\s+1/4|1\s+1/2|1/2|3/4|2|1)([\b\D]|$)");
protected virtual string _title { get; } = string.Empty;
public virtual bool TryParse(string input, out string output)
{
var match = _diameter.Match(input);
if (match.Success)
{
output = $"{_title} {match.Groups["Diameter"]}";
return true;
}
else
{
output = string.Empty;
return false;
}
}
}